- Setting up flask app in terminal:
- In Windows:
set FLASK_APP=server.py - In Linux:
export FLASK_APP=server.py
- In Windows:
- To run the server:
flask run
Note: if run on an Azure instance for example the application will be killed when you close the ssh connection. Instead use tmux:
- Start a tmux session:
tmux - Do the steps from above here
- Exit the
tmuxwindow by pressingctrl+band thend(detach) - To enter a running tmux session:
tmux attach - To close it: go into the session and write
exit
Optional:
- to run flask app in debug mode
set FLASK_DEBUG=1orexport FLASK_DEBUG=1before running the server. - if
LOGFILEis specified in.envthe logger will write to that file. - if
UPLOAD_DIRECTORYin.envis not specified it will default toapi_uploaded_files
- List uploaded files (No authentication required): GET request to
<server-ip>/files - Upload files: POST request to
<server-ip>/files/<file-name-with-extension>with allowedAPI-keyin header (file may be renamed due tosecure_filename()-function from flask) and file as attachment - Download files: GET request to
<server-ip>/files/<file-name-with-extension>with allowedAPI-keyin header
Uploading and downloading is only possible when the user gives an API-key that is also in the .env-file of the server in the ALLOWED_KEYS-variable.
- flask
- dotenv