aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
blob: b678aaebcbb1a522a6658b93c62ff6d6f4156225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sanic
import os

import controller

app = sanic.Sanic("Files")

@app.get("/")
async def index(request):
    return controller.index()

@app.post("/", stream = True)
async def upload(request):
    return await controller.upload(request)

@app.get("/<file_id:str>")
async def file_page(request, file_id):
    return await controller.file(file_id, download = False)

@app.get("/<file_id:str>/download")
async def file_download(request, file_id):
    return await controller.file(file_id, download = True)

app.static("/static/", "static/")

if __name__ == "__main__":
    debug = 'DEBUG' in os.environ and os.environ['DEBUG'] == 'TRUE'
    app.run(debug=debug, access_log=True)