- 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
tmux
window by pressingctrl
+b
and 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=1
orexport FLASK_DEBUG=1
before running the server. - if
LOGFILE
is specified in.env
the logger will write to that file. - if
UPLOAD_DIRECTORY
in.env
is 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-key
in 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-key
in 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