Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,8 @@ import os
|
|
| 5 |
import threading
|
| 6 |
import time
|
| 7 |
import urllib.parse
|
| 8 |
-
from fastapi import FastAPI, UploadFile, File, HTTPException, Form
|
| 9 |
-
from fastapi.responses import JSONResponse
|
| 10 |
-
from fastapi.staticfiles import StaticFiles
|
| 11 |
-
from fastapi.templating import Jinja2Templates
|
| 12 |
import json
|
| 13 |
import io
|
| 14 |
from pathlib import Path
|
|
@@ -24,10 +22,6 @@ app = FastAPI(
|
|
| 24 |
description="Processes images to detect cursors and uploads results to dataset"
|
| 25 |
)
|
| 26 |
|
| 27 |
-
# Setup static files and templates
|
| 28 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 29 |
-
templates = Jinja2Templates(directory="templates")
|
| 30 |
-
|
| 31 |
# --- Environment Configuration ---
|
| 32 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
| 33 |
HF_DATASET_ID = os.getenv("HF_DATASET_ID", "Fred808/data") # Dataset to store results
|
|
@@ -489,15 +483,6 @@ async def track_cursor_url_endpoint(
|
|
| 489 |
detail=f"An error occurred while processing the image: {str(e)}"
|
| 490 |
)
|
| 491 |
|
| 492 |
-
@app.get("/templates")
|
| 493 |
-
async def list_templates():
|
| 494 |
-
"""Returns a list of all loaded cursor template names."""
|
| 495 |
-
return {"templates": list(CURSOR_TEMPLATES.keys()), "count": len(CURSOR_TEMPLATES)}
|
| 496 |
-
|
| 497 |
-
@app.get("/", response_class=HTMLResponse)
|
| 498 |
-
async def home(request: Request):
|
| 499 |
-
return templates.TemplateResponse("home.html", {"request": request})
|
| 500 |
-
|
| 501 |
# Get the port from environment variable
|
| 502 |
port = int(os.environ.get("PORT", 7860))
|
| 503 |
|
|
|
|
| 5 |
import threading
|
| 6 |
import time
|
| 7 |
import urllib.parse
|
| 8 |
+
from fastapi import FastAPI, UploadFile, File, HTTPException, Form
|
| 9 |
+
from fastapi.responses import JSONResponse
|
|
|
|
|
|
|
| 10 |
import json
|
| 11 |
import io
|
| 12 |
from pathlib import Path
|
|
|
|
| 22 |
description="Processes images to detect cursors and uploads results to dataset"
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# --- Environment Configuration ---
|
| 26 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
| 27 |
HF_DATASET_ID = os.getenv("HF_DATASET_ID", "Fred808/data") # Dataset to store results
|
|
|
|
| 483 |
detail=f"An error occurred while processing the image: {str(e)}"
|
| 484 |
)
|
| 485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
# Get the port from environment variable
|
| 487 |
port = int(os.environ.get("PORT", 7860))
|
| 488 |
|