Compare commits

...

2 commits

Author SHA1 Message Date
60ee4afe2e Изменил докер 2024-02-12 13:00:18 +03:00
a6689f916d Изменил докер 2024-02-12 12:59:38 +03:00
4 changed files with 8 additions and 10 deletions

View file

@ -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}

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

View file

@ -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