Spaces:
Runtime error
Runtime error
Topallaj Denis
commited on
Commit
•
0879a7e
1
Parent(s):
e2a3b95
init, test
Browse files- Dockerfile +14 -0
- requirements.txt +3 -0
- server.py +21 -0
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.11-slim
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.110.0
|
2 |
+
uvicorn==0.29.0
|
3 |
+
requests==2.31.0
|
server.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
3 |
+
import uvicorn
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
|
7 |
+
# Add CORS middleware
|
8 |
+
app.add_middleware(
|
9 |
+
CORSMiddleware,
|
10 |
+
allow_origins=["*"],
|
11 |
+
allow_methods=["*"],
|
12 |
+
allow_headers=["*"]
|
13 |
+
)
|
14 |
+
|
15 |
+
@app.get("/")
|
16 |
+
def read_root():
|
17 |
+
return {"Hello": "World"}
|
18 |
+
|
19 |
+
|
20 |
+
if __name__ == "__main__":
|
21 |
+
uvicorn.run("server:app", host="localhost", port=8000, reload=True)
|