Spaces:
Sleeping
Sleeping
Commit
·
9d02239
1
Parent(s):
14862a6
Test dans le container
Browse files- Dockerfile +16 -0
- app.py +18 -0
- requirements.txt +26 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
RUN useradd -m -u 1000 user
|
7 |
+
USER user
|
8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
9 |
+
|
10 |
+
WORKDIR /app
|
11 |
+
|
12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
14 |
+
|
15 |
+
COPY --chown=user . /app
|
16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, UploadFile, File
|
2 |
+
from fastapi.responses import FileResponse
|
3 |
+
import os
|
4 |
+
import shutil
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
@app.get("/")
|
9 |
+
def greet_json():
|
10 |
+
return {"Hello": "World!"}
|
11 |
+
|
12 |
+
@app.post("/upload")
|
13 |
+
async def upload_file(file: UploadFile = File(...)):
|
14 |
+
os.makedirs("uploads", exist_ok=True)
|
15 |
+
file_location = f"uploads/{file.filename}"
|
16 |
+
with open(file_location, "wb") as f:
|
17 |
+
shutil.copyfileobj(file.file, f)
|
18 |
+
return FileResponse(path=file_location, filename=file.filename)
|
requirements.txt
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotated-types==0.7.0
|
2 |
+
anyio==4.9.0
|
3 |
+
blinker==1.9.0
|
4 |
+
certifi==2025.4.26
|
5 |
+
click==8.1.8
|
6 |
+
fastapi==0.115.12
|
7 |
+
Flask==3.1.0
|
8 |
+
h11==0.16.0
|
9 |
+
idna==3.10
|
10 |
+
importlib_metadata==8.6.1
|
11 |
+
itsdangerous==2.2.0
|
12 |
+
Jinja2==3.1.6
|
13 |
+
MarkupSafe==2.1.5
|
14 |
+
pip==25.1.1
|
15 |
+
pydantic==2.11.4
|
16 |
+
pydantic_core==2.33.2
|
17 |
+
python-multipart==0.0.20
|
18 |
+
setuptools==80.1.0
|
19 |
+
sniffio==1.3.1
|
20 |
+
starlette==0.46.2
|
21 |
+
typing_extensions==4.13.2
|
22 |
+
typing-inspection==0.4.0
|
23 |
+
uvicorn==0.34.2
|
24 |
+
Werkzeug==3.1.3
|
25 |
+
wheel==0.45.1
|
26 |
+
zipp==3.21.0
|