Spaces:
Runtime error
Runtime error
Commit ·
bd0d429
1
Parent(s): 89b3d14
Add basic FastAPI app
Browse files- app.py +11 -0
- requirements.txt +2 -0
- start.sh +2 -0
app.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
|
| 3 |
+
app = FastAPI()
|
| 4 |
+
|
| 5 |
+
@app.get("/")
|
| 6 |
+
def home():
|
| 7 |
+
return {"message": "Hello from FastAPI on Hugging Face Spaces!"}
|
| 8 |
+
|
| 9 |
+
@app.get("/greet")
|
| 10 |
+
def greet(name: str = "Maroof"):
|
| 11 |
+
return {"greeting": f"Hello, {name}!"}
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
start.sh
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pip install -r requirements.txt
|
| 2 |
+
uvicorn app:app --host 0.0.0.0 --port 7860
|