This repository has been archived on 2024-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
python-api-server/README.md

105 lines
1.6 KiB
Markdown
Raw Normal View History

2023-04-13 14:50:46 +02:00
# python-api-server
2023-04-13 14:21:15 +02:00
2023-04-13 15:29:16 +02:00
a small flask-application for storing and downloading stuff like small binaries
2023-04-13 14:21:15 +02:00
2023-04-13 14:50:46 +02:00
## Variables
2023-04-13 14:21:15 +02:00
2023-04-14 07:41:42 +02:00
- ``MAX_CONTENT_LENGTH``: maximal Filesize in MB; defaults to 5MB
- ``UPLOAD_DIRECTORY``: where to store the uploaded files; should be mapped to a volume; defaults to "/uploads"
- ``AUTH_TOKEN``: token used for authenticating
2023-04-13 14:50:46 +02:00
## Example Docker-Compose
see [docker-compose.yml](./docker-compose.yml)
## API-Endpoints
### /list
#### input
```bash
curl -H "token: myuploadtoken" http://docker10.host.lan:5040/list | jq
```
#### output
```bash
{
"files": [
{
"last_modified": "2023-04-13 11:43:51",
"name": "file1",
"size": 1034
},
{
"last_modified": "2023-04-13 11:53:59",
"name": "file2",
"size": 5
},
{
"last_modified": "2023-04-13 12:41:18",
"name": "file3",
"size": 3478
}
]
}
```
### /upload
2023-04-14 07:41:16 +02:00
If a existing file has the same name as the newly uploaded file, it will be overwritten.
2023-04-13 14:50:46 +02:00
#### input
```bash
curl -X POST -H "token: myuploadtoken" -F "file=@tests/file" http://docker10.host.lan:5040/upload | jq
```
#### output
```bash
{
"success": "File 'file' successfully uploaded"
}
```
### /download
#### input
```bash
wget http://docker10.host.lan:5040/download/file
```
### /delete
#### input
```bash
curl -X DELETE -H "token: myuploadtoken" http://docker10.host.lan:5040/delete/file | jq
```
#### output
```bash
{
"success": "File 'file' successfully deleted"
}
```
2023-04-14 12:17:08 +02:00
### /health
#### input
```bash
2023-04-14 12:20:04 +02:00
curl http://docker10.host.lan:5040/health
2023-04-14 12:17:08 +02:00
```
#### output
```bash
OK
```