Spaces:
Sleeping
Sleeping
Upload main.py with huggingface_hub
Browse files
main.py
CHANGED
|
@@ -4,6 +4,9 @@ import os
|
|
| 4 |
sys.path.insert(0, os.path.dirname(__file__))
|
| 5 |
|
| 6 |
from fastapi import FastAPI, HTTPException
|
|
|
|
|
|
|
|
|
|
| 7 |
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
from typing import Dict, Any
|
| 9 |
from models import Action, StepResult, Reward
|
|
@@ -22,6 +25,10 @@ app = FastAPI(
|
|
| 22 |
version="1.0.0"
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
app.add_middleware(
|
| 26 |
CORSMiddleware,
|
| 27 |
allow_origins=["*"],
|
|
@@ -61,6 +68,10 @@ def get_env(task_id: str) -> DataCleaningEnv:
|
|
| 61 |
# ROUTES
|
| 62 |
# βββββββββββββββββββββββββββββββββββββββββ
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@app.get("/")
|
| 65 |
def root():
|
| 66 |
return {
|
|
|
|
| 4 |
sys.path.insert(0, os.path.dirname(__file__))
|
| 5 |
|
| 6 |
from fastapi import FastAPI, HTTPException
|
| 7 |
+
from fastapi.staticfiles import StaticFiles
|
| 8 |
+
from fastapi.responses import FileResponse
|
| 9 |
+
import os
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
from typing import Dict, Any
|
| 12 |
from models import Action, StepResult, Reward
|
|
|
|
| 25 |
version="1.0.0"
|
| 26 |
)
|
| 27 |
|
| 28 |
+
# Serve UI
|
| 29 |
+
os.makedirs("static", exist_ok=True)
|
| 30 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 31 |
+
|
| 32 |
app.add_middleware(
|
| 33 |
CORSMiddleware,
|
| 34 |
allow_origins=["*"],
|
|
|
|
| 68 |
# ROUTES
|
| 69 |
# βββββββββββββββββββββββββββββββββββββββββ
|
| 70 |
|
| 71 |
+
@app.get("/ui")
|
| 72 |
+
def ui():
|
| 73 |
+
return FileResponse("static/index.html")
|
| 74 |
+
|
| 75 |
@app.get("/")
|
| 76 |
def root():
|
| 77 |
return {
|