added README.md and more documentation

This commit is contained in:
Todor Bogosavljević 2024-08-23 16:26:14 +02:00
parent 427342a47a
commit 571aebf027

View File

@ -1,3 +1,71 @@
# upload.x1b.dev # x1b / upload
A simple one file upload script to push images to the cloud. 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!