2024-08-23 16:44:51 +02:00
2024-08-23 12:28:28 +02:00
2024-08-23 12:28:12 +02:00
2024-08-23 12:28:12 +02:00

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:

{
    "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.

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!

Description
No description provided
Readme 41 KiB
Languages
Python 71%
HTML 29%