Skip to content

Simple token authenticated API for uploading and downloading files. Codeberg mirror (not in sync).

Notifications You must be signed in to change notification settings

jasalt/nanodjango-fileapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple server application written using nanodjango which is a single file approach to using Django. Rewrite of an earlier project where full Django project structure did not feel right.

Application allows uploading and downloading files with authentication by API_TOKEN set in .env or as environment variable.

Original use case was to allow transferring CSV files from machine behind firewall to a public endpoint accessible by Grafana Cloud Infinity Data Source to make it available on a dashboard.

API usage example

# Upload file
curl -X POST http://localhost:8000/api/upload -F '[email protected]'

# Download file
curl -H 'Authorization: Bearer <API_TOKEN>' http://localhost:8000/api/download\?file\=myfile.txt

Installing and running

Clone repository and install dependencies stated in pyproject.toml and run nanodjango run server.py. Server should start listening on port 8000.

Usage example with uv which is a new Python environment manager tool by ruff team written in rust:

# Install uv
# curl -LsSf https://astral.sh/uv/install.sh | sh

cp .env.example .env  # and edit it or alternatively set AUTH_TOKEN env var

uv sync
uv run nanodjango run server.py

Documentation here is in progress and has not been tested on another machine yet..

TODO

  • Test on another machine (may require adding /static dir to repo as is) and finish installation docs
  • Container with uv
  • Caddy deployment
  • Coolify deployment as Dockerfile

Known issues and used workarounds

Code violates PEP8 (related django-ninja issue) and includes ignore rules for Ruff.

About

Simple token authenticated API for uploading and downloading files. Codeberg mirror (not in sync).

Resources

Stars

Watchers

Forks

Languages