Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,18 @@
|
|
| 1 |
-
from
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
app =
|
| 5 |
-
# Enable CORS for all domains on all routes
|
| 6 |
-
CORS(app, resources={r"/api/*": {"origins": "https://hamza82-test.hf.space"}})
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.staticfiles import StaticFiles
|
| 3 |
+
from fastapi.responses import FileResponse
|
| 4 |
|
| 5 |
+
app = FastAPI()
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Mount the 'static' directory to serve static files.
|
| 8 |
+
# Assuming your static files are in a directory named 'static'.
|
| 9 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 10 |
|
| 11 |
+
@app.get("/")
|
| 12 |
+
def read_root():
|
| 13 |
+
# Serve your static HTML file at the root.
|
| 14 |
+
return FileResponse('static/index.html')
|
| 15 |
+
|
| 16 |
+
@app.get("/api")
|
| 17 |
+
def read_api():
|
| 18 |
+
return {"message": "Hello from the FastAPI API!"}
|