Simple upload service with TOTP support, made with Python Flask
.forgejo/workflows | ||
templates | ||
.gitignore | ||
Dockerfile | ||
LICENSE | ||
README.md | ||
server.py |
FastFile
Simple upload service with TOTP support, made with Python Flask.
This is basically an open-sourced + enhanced version of the one I had in my old PythonAnywhere site.
Features
- TOTP authentication
- View both frontend and raw files
- Object storage support (kind of)
- With environment variable
FASTFILE_REALRAWURL=https://cdn.example.com/somefile/
(Must end with /) - And with environment variable
FASTFILE_RCLONE_REMOTE=remote:directory_or_bucket/
(Must end with /) - Need to add rclone config to volumes if using docker
- With environment variable
Installation
Via Docker
Create this docker-compose.yml
file in an empty directory:
services:
fastfile:
image: git.swee.codes/swee/fastfile:latest
restart: unless-stopped
ports:
- 2007:2007
environment:
- FASTFILE_TOTPKEY=totp_key_here
- FASTFILE_FILEPATH=/files/ # # Replace with whatever you want to store files in - Must end with /
# - FASTFILE_RCLONE_REMOTE=r2demo:fastfile/
volumes:
- ./files:/files
- ./cache.json:/app/cache.json
# - /home/user/.config/rclone/rclone.conf:/root/.config/rclone/rclone.conf
And run this:
mkdir files
touch cache.json
docker compose up -d
Directly
Install packages:
Directly: pip install flask gunicorn pytotp magic
Debian/Ubuntu: sudo apt install python3-flask python3-gunicorn python3-pyotp python3-magic
Alpine: apk add py3-flask py3-gunicorn py3-otp py3-magic
Run:
export FASTFILE_TOTPKEY=totp_key_here
export FASTFILE_FILEPATH=/home/user/files/ # Replace with whatever you want to store files in - Must end with /
gunicorn -w --bind=0.0.0.0:2007 server:app
How to get TOTP key?
Install the pyotp
(py3-otp
in alpine) as shown above, run
python3 -c "import pyotp; print(pyotp.random_base32())"
Copy the output and use in your environment variable.