Compare commits

...

2 commits

4 changed files with 36 additions and 4 deletions

10
.dockerignore Normal file
View file

@ -0,0 +1,10 @@
.venv
.idea
.gitignore
bp/images/*
bp/backgrounds/*
bp/avatars/*
app/static/images/images/
app/static/images/backgrounds/
app/static/images/avatars/

7
.gitignore vendored
View file

@ -162,3 +162,10 @@ cython_debug/
node_modules
.env_non_dev
bp/images/*
bp/backgrounds/*
bp/avatars/*
app/static/images/images/*
app/static/images/backgrounds/*
app/static/images/avatars/*

View file

@ -37,14 +37,29 @@ app.add_middleware(
app.mount("/static", StaticFiles(directory="app/static"), name="static")
@app.post('/images', response_model=dict[str, str])
async def upload_images(file: UploadFile):
@app.post('/upload_avatar', response_model=dict[str, str])
async def upload_avatar(file: UploadFile):
name = generate_random_string()
image_url = f'static/images/{name}_avatar.png'
image_url = f'static/images/avatars/{name}_avatar.png'
with open('app/' + image_url, 'wb+') as file_object:
shutil.copyfileobj(file.file, file_object)
return {'image_url': image_url}
@app.post('/upload_background', response_model=dict[str, str])
async def upload_background(file: UploadFile):
name = file.filename.split('.')[0]
file_format = file.filename.split('.')[-1]
image_url = f'static/images/backgrounds/{name}_background.{file_format}'
with open('app/' + image_url, 'wb+') as file_object:
shutil.copyfileobj(file.file, file_object)
return {'image_url': image_url}
@app.post('/upload_image', response_model=dict[str, str])
async def upload_image(file: UploadFile):
name = generate_random_string(50)
image_url = f'static/images/images/{name}_image.png'
with open('app/' + image_url, 'wb+') as file_object:
shutil.copyfileobj(file.file, file_object)
return {'image_url': image_url}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB