Spaces:
Sleeping
Sleeping
fix: Update root endpoint to use dynamic URLs and improve API info
Browse files- backend/main.py +27 -14
backend/main.py
CHANGED
|
@@ -7,7 +7,7 @@ Clean and simple FastAPI application for GPS coordinate extraction and validatio
|
|
| 7 |
import logging
|
| 8 |
import uvicorn
|
| 9 |
from pathlib import Path
|
| 10 |
-
from fastapi import FastAPI
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
from fastapi.responses import FileResponse
|
|
@@ -66,26 +66,39 @@ if frontend_path.exists():
|
|
| 66 |
return FileResponse(str(frontend_path / "index.html"))
|
| 67 |
|
| 68 |
@app.get("/")
|
| 69 |
-
async def root():
|
| 70 |
"""Root endpoint with API information"""
|
|
|
|
|
|
|
|
|
|
| 71 |
return {
|
| 72 |
-
"
|
| 73 |
-
"
|
| 74 |
-
"description": "GPS
|
| 75 |
-
"ui": "http://localhost:8000/ui",
|
| 76 |
"features": [
|
| 77 |
-
"GPS extraction from image EXIF
|
| 78 |
-
"OCR text extraction using Tesseract",
|
| 79 |
-
"WhatsApp GPS overlay detection",
|
| 80 |
-
"Location validation against
|
|
|
|
| 81 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"endpoints": {
|
| 83 |
-
"web_ui": "GET /ui",
|
| 84 |
"validate_image": "POST /api/v1/validate-image-location",
|
| 85 |
-
"
|
| 86 |
"list_zones": "GET /api/v1/zones",
|
| 87 |
-
"health_check": "GET /api/v1/health"
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
}
|
| 91 |
|
|
|
|
| 7 |
import logging
|
| 8 |
import uvicorn
|
| 9 |
from pathlib import Path
|
| 10 |
+
from fastapi import FastAPI, Request
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
from fastapi.responses import FileResponse
|
|
|
|
| 66 |
return FileResponse(str(frontend_path / "index.html"))
|
| 67 |
|
| 68 |
@app.get("/")
|
| 69 |
+
async def root(request: Request):
|
| 70 |
"""Root endpoint with API information"""
|
| 71 |
+
# Get the base URL dynamically
|
| 72 |
+
base_url = str(request.base_url).rstrip('/')
|
| 73 |
+
|
| 74 |
return {
|
| 75 |
+
"message": "GPS Verifier API v3.0.0 - LPU Location Validation System",
|
| 76 |
+
"status": "running",
|
| 77 |
+
"description": "Extract GPS coordinates from images and validate against Lovely Professional University campus boundaries",
|
|
|
|
| 78 |
"features": [
|
| 79 |
+
"๐ธ GPS extraction from image EXIF metadata",
|
| 80 |
+
"๐ OCR text extraction using Tesseract",
|
| 81 |
+
"๐ฑ WhatsApp GPS overlay detection",
|
| 82 |
+
"๐บ๏ธ Location validation against LPU campus zones",
|
| 83 |
+
"โจ Real-time coordinate verification"
|
| 84 |
],
|
| 85 |
+
"links": {
|
| 86 |
+
"web_ui": f"{base_url}/ui",
|
| 87 |
+
"api_docs": f"{base_url}/docs",
|
| 88 |
+
"redoc": f"{base_url}/redoc",
|
| 89 |
+
"health_check": f"{base_url}/api/v1/health"
|
| 90 |
+
},
|
| 91 |
"endpoints": {
|
|
|
|
| 92 |
"validate_image": "POST /api/v1/validate-image-location",
|
| 93 |
+
"validate_coordinates": "POST /api/v1/validate-coordinates",
|
| 94 |
"list_zones": "GET /api/v1/zones",
|
| 95 |
+
"health_check": "GET /api/v1/health"
|
| 96 |
+
},
|
| 97 |
+
"tech_stack": {
|
| 98 |
+
"framework": "FastAPI",
|
| 99 |
+
"ocr": "Tesseract + OpenCV",
|
| 100 |
+
"geospatial": "Shapely",
|
| 101 |
+
"deployment": "Hugging Face Spaces (Docker)"
|
| 102 |
}
|
| 103 |
}
|
| 104 |
|