Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -6,6 +6,16 @@ from fastapi.staticfiles import StaticFiles
|
|
6 |
from pydantic import BaseModel
|
7 |
from typing import Optional, Any
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Check whether we are executing inside a Hugging Face Space
|
10 |
SPACE_NAME = os.getenv("SPACE_NAME", default=None)
|
11 |
if SPACE_NAME is not None:
|
@@ -28,9 +38,6 @@ model_id = "152334H/miqu-1-70b-sf"
|
|
28 |
endpoint = f"https://api-inference.huggingface.co/models/{model_id}"
|
29 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_TOKEN}"}
|
30 |
|
31 |
-
# App definition
|
32 |
-
app = FastAPI()
|
33 |
-
|
34 |
# Helper function to read raw request bodies
|
35 |
async def parse_raw(request: Request):
|
36 |
return await request.body()
|
|
|
6 |
from pydantic import BaseModel
|
7 |
from typing import Optional, Any
|
8 |
|
9 |
+
app = FastAPI()
|
10 |
+
|
11 |
+
# Mount the static folder
|
12 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
13 |
+
|
14 |
+
# Define a route for the root URL to serve the index.html file
|
15 |
+
@app.get("/", include_in_schema=False)
|
16 |
+
async def root():
|
17 |
+
return {"file_path": "static/index.html"}
|
18 |
+
|
19 |
# Check whether we are executing inside a Hugging Face Space
|
20 |
SPACE_NAME = os.getenv("SPACE_NAME", default=None)
|
21 |
if SPACE_NAME is not None:
|
|
|
38 |
endpoint = f"https://api-inference.huggingface.co/models/{model_id}"
|
39 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_TOKEN}"}
|
40 |
|
|
|
|
|
|
|
41 |
# Helper function to read raw request bodies
|
42 |
async def parse_raw(request: Request):
|
43 |
return await request.body()
|