Compare commits
2 commits
4f358c5030
...
60ee4afe2e
Author | SHA1 | Date | |
---|---|---|---|
60ee4afe2e | |||
a6689f916d |
4 changed files with 8 additions and 10 deletions
|
@ -15,10 +15,10 @@ def generate_random_string(length=16):
|
|||
|
||||
app = FastAPI(
|
||||
prefix="/api",
|
||||
tags=["Сервак для загрузки"]
|
||||
tags=["Сервак для загрузки"],
|
||||
)
|
||||
|
||||
origins = ['*']
|
||||
origins = []
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
@ -40,8 +40,8 @@ app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
|||
@app.post('/images', response_model=dict[str, str])
|
||||
async def upload_images(file: UploadFile):
|
||||
name = generate_random_string()
|
||||
image_url = f'app/static/images/{name}_avatar.png'
|
||||
with open(image_url, 'wb+') as file_object:
|
||||
image_url = f'static/images/{name}_avatar.png'
|
||||
with open('app/' + image_url, 'wb+') as file_object:
|
||||
shutil.copyfileobj(file.file, file_object)
|
||||
return {'image_url': image_url}
|
||||
|
||||
|
|
BIN
app/static/images/WydCxlHkhDVjZFu5_avatar.png
Normal file
BIN
app/static/images/WydCxlHkhDVjZFu5_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
BIN
bp/9r3IBte2WYjpceAK_avatar.png
Normal file
BIN
bp/9r3IBte2WYjpceAK_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
|
@ -1,12 +1,10 @@
|
|||
version: '3'
|
||||
version: '3.8'
|
||||
services:
|
||||
uploader_server:
|
||||
image: uploader_server
|
||||
build:
|
||||
context: .
|
||||
image: urec56/uploader_server
|
||||
container_name: uploader_server
|
||||
ports:
|
||||
- 127.0.0.1:7777:8000
|
||||
- 127.0.0.1:55555:8000
|
||||
restart: always
|
||||
volumes:
|
||||
- ./bp:/BP
|
||||
- ./bp:/BP/app/static/images
|
||||
|
|
Loading…
Add table
Reference in a new issue