networking

This commit is contained in:
Egor Matveev
2022-03-28 12:28:13 +03:00
parent c6383ffb31
commit f26b530ff8
6 changed files with 36 additions and 61 deletions

View File

@@ -5,7 +5,5 @@ from aiohttp import web
async def delete_file(request):
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
return web.json_response({"success": False}, status=403)
remove("data/" + request.rel_url.query['id'])
return web.json_response({"success": True})

View File

@@ -5,8 +5,6 @@ from aiohttp import web
async def get_file(request):
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
return web.json_response({"success": False}, status=403)
response = web.StreamResponse()
await response.prepare(request)
async with aiofiles.open("data/" + request.rel_url.query['id'], "rb") as fs:

View File

@@ -7,8 +7,6 @@ import aiofiles
async def upload_file(request):
if 'token' not in request.headers or request.headers['token'] != os.getenv('FS_TOKEN'):
return web.json_response({"success": False}, status=403)
file_id = await write_meta(request)
async with aiofiles.open("data/" + str(file_id), "wb") as fs:
await fs.write(await request.content.read())