71 lines
2.1 KiB
Markdown
71 lines
2.1 KiB
Markdown
# x1b / upload
|
|
|
|
A very minimal script to host a fully-fledged file upload & URL shortening service. It is under a 100 lines of Python code, and is fully customizable with an external configuration file.
|
|
|
|
It features:
|
|
- File upload
|
|
- URL shortening
|
|
- Size limits
|
|
- Time limits
|
|
- A landing page
|
|
- Customizable with an external file
|
|
|
|
## Usage
|
|
|
|
You can push files to it using the following command:
|
|
`curl -F file=@your_file up.x1b.dev.com`
|
|
|
|
You can shorten URL's by using this command and providing the target URL:
|
|
`curl -d "url=https://example.com" up.x1b.dev`
|
|
|
|
After any action you will get a URL with a 6-character key like:
|
|
`https://up.x1b.dev.com/xg29a6`
|
|
|
|
## Requirements
|
|
|
|
To run this you will need the following packages:
|
|
|
|
- Default Python packages (os, requests, etc.)
|
|
- Flask
|
|
- SQlite3
|
|
|
|
## Setup
|
|
|
|
After installing the required packages, you can configure your instance, and run the main python script with:
|
|
`python3 main.py`
|
|
|
|
Everything will be set up automatically for a first-time run.
|
|
|
|
## Configuration
|
|
|
|
The example configuration file looks like this:
|
|
```json
|
|
{
|
|
"upload_folder": "./uploads",
|
|
"max_file_size": 104857600,
|
|
"expiration_time": 604800,
|
|
"data_file": "data.db",
|
|
"base_url": "http://localhost:5000/",
|
|
"name": "up.x1b.dev"
|
|
}```
|
|
|
|
And here is what the fields mean:
|
|
|
|
upload_folder - the folder where the uploads will be stored
|
|
max_file_size - maximum upload file size in bytes
|
|
expiration_time - how long files take to expire in seconds
|
|
data_file - sqlite3 database file
|
|
base_url - your domain url
|
|
name - what your website is called (doesn't have to be same as domain name)
|
|
|
|
#### Reverse proxy
|
|
|
|
You may want to set this up on a domain name, and not using the server IP. You can do this with a reverse proxy.
|
|
|
|
You can find documentation on how to set up a [reverse proxy with nginx here](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/).
|
|
|
|
## Contribution
|
|
|
|
Feel free to open pull requests to implement features, or issues to request features / report problems. The only rule is to keep the `main.py` file under 100 lines of code.
|
|
|
|
Thanks for reading, and happy uploading! |