Изменил докер
This commit is contained in:
parent
4f358c5030
commit
a6689f916d
4 changed files with 7 additions and 7 deletions
|
@ -15,10 +15,10 @@ def generate_random_string(length=16):
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
prefix="/api",
|
prefix="/api",
|
||||||
tags=["Сервак для загрузки"]
|
tags=["Сервак для загрузки"],
|
||||||
)
|
)
|
||||||
|
|
||||||
origins = ['*']
|
origins = []
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
|
@ -40,8 +40,8 @@ app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||||
@app.post('/images', response_model=dict[str, str])
|
@app.post('/images', response_model=dict[str, str])
|
||||||
async def upload_images(file: UploadFile):
|
async def upload_images(file: UploadFile):
|
||||||
name = generate_random_string()
|
name = generate_random_string()
|
||||||
image_url = f'app/static/images/{name}_avatar.png'
|
image_url = f'static/images/{name}_avatar.png'
|
||||||
with open(image_url, 'wb+') as file_object:
|
with open('app/' + image_url, 'wb+') as file_object:
|
||||||
shutil.copyfileobj(file.file, file_object)
|
shutil.copyfileobj(file.file, file_object)
|
||||||
return {'image_url': image_url}
|
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,7 +1,7 @@
|
||||||
version: '3'
|
version: '3.8'
|
||||||
services:
|
services:
|
||||||
uploader_server:
|
uploader_server:
|
||||||
image: uploader_server
|
image: urec56/uploader_server
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
container_name: uploader_server
|
container_name: uploader_server
|
||||||
|
@ -9,4 +9,4 @@ services:
|
||||||
- 127.0.0.1:7777:8000
|
- 127.0.0.1:7777:8000
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./bp:/BP
|
- ./bp:/BP/app/static/images
|
||||||
|
|
Loading…
Add table
Reference in a new issue