Compare commits
2 commits
637f0401da
...
f5ba50e65e
Author | SHA1 | Date | |
---|---|---|---|
f5ba50e65e | |||
78d7b3a412 |
4 changed files with 36 additions and 4 deletions
10
.dockerignore
Normal file
10
.dockerignore
Normal 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/
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -161,4 +161,11 @@ cython_debug/
|
|||
.idea/
|
||||
|
||||
node_modules
|
||||
.env_non_dev
|
||||
.env_non_dev
|
||||
|
||||
bp/images/*
|
||||
bp/backgrounds/*
|
||||
bp/avatars/*
|
||||
app/static/images/images/*
|
||||
app/static/images/backgrounds/*
|
||||
app/static/images/avatars/*
|
||||
|
|
21
app/main.py
21
app/main.py
|
@ -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 |
Loading…
Add table
Reference in a new issue