API Init
Browse files- .DS_Store +0 -0
- .gitignore +2 -0
- Dockerfile +9 -0
- app.py +16 -0
- requirements.txt +2 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
__pycache__
|
2 |
+
venv
|
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY . /app
|
6 |
+
|
7 |
+
RUN pip install -r requirements.txt
|
8 |
+
|
9 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
|
3 |
+
app = FastAPI()
|
4 |
+
|
5 |
+
# Define a route
|
6 |
+
@app.get("/api/greet")
|
7 |
+
def greet(name: str = "World"):
|
8 |
+
return {"message": f"Hello, {name}!"}
|
9 |
+
|
10 |
+
# Run the server (use Uvicorn)
|
11 |
+
# Command: uvicorn app:app --reload
|
12 |
+
|
13 |
+
@app.get("/")
|
14 |
+
def read_root():
|
15 |
+
return {"message": "Hello from Hugging Face Spaces!"}
|
16 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn
|