/fileguru

Django, django.

Primary LanguagePython

Running locally

No special setup required, install requirements and runserver it up! Example with virtualenv:

virtualenv VENV -p python
source VENV/bin/activate
pip install -r requirements.txt
./manage.py runserver

Code formatting and linting

All code has been formatted with black. Imports have been sorted with isort.

There's a format.sh file inside code/ to do those plus autoflake (for unused imports removal) in one shot.

API Authorization

DRF's TokenAuthentication has been set up for the API views (where applicable). You'll have to create a Token inside the admin panel before you can make requests to /upload and /summary.

Token needs to be provided in the standard Authorization: Token <token> way.

Settings

Two app-specific settings have been added to settings.py:

  • UPLOAD_PASSWORD_LENGTH determines how long the autogenerated passphrase for an uploaded resource should be
  • UPLOAD_EXPIRY_HOURS determines after how many hours the upload becomes inaccessible
  • BASE_APP_URL set this to the root URL of wherever the app is deployed to build nice, complete URLs

Commands

A createuser command has been added to help out with creating users for local testing and development.

It takes a username as an argument, and if the optional --email flag is not provided, will use a <username>@example.com address instead.

Asks for password via getpass().

An API token is automatically created and printed, unless --no-token is passed.

Extras

Add a Django system check to see if BASE_APP_URL is configured and warn early about the consequences.

Dependencies

Nothing extra special, apart from freezegun for expiry testing, though it is a bit overkill for this case.

Tests

Nothing special (no pytest, no nose) just ./manage.py test.

There is a .har file which you should be able to import into Insomnia or any other desktop HTTP client for manual API tests.