feat: use forms for course creation

This commit is contained in:
swve 2022-10-14 22:27:13 +02:00
parent 3581b4409f
commit 9a8e4e4492
4 changed files with 33 additions and 21 deletions

12
src/services/uploads.py Normal file
View file

@ -0,0 +1,12 @@
async def upload_thumbnail(thumbnail_file, name_in_disk):
contents = thumbnail_file.file.read()
try:
with open(f"content/uploads/img/{name_in_disk}", 'wb') as f:
f.write(contents)
f.close()
except Exception as e:
print(e)
return {"message": "There was an error uploading the file"}
finally:
thumbnail_file.file.close()