Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from contextlib import asynccontextmanager
|
|
| 7 |
from datetime import datetime, timedelta
|
| 8 |
from urllib.parse import urlparse
|
| 9 |
from fastapi import FastAPI, Query, BackgroundTasks
|
| 10 |
-
from fastapi.responses import JSONResponse
|
| 11 |
from rapidfuzz import process, fuzz
|
| 12 |
from cryptography.fernet import Fernet
|
| 13 |
|
|
@@ -107,7 +107,7 @@ def check_adult_content(query: str) -> bool:
|
|
| 107 |
def ai_fallback_search(query: str):
|
| 108 |
return {
|
| 109 |
"ai_fallback_triggered": True,
|
| 110 |
-
"message": f"
|
| 111 |
"results": [
|
| 112 |
{
|
| 113 |
"url": f"https://www.google.com/search?q={query.replace(' ', '+')}",
|
|
@@ -120,7 +120,11 @@ def ai_fallback_search(query: str):
|
|
| 120 |
]
|
| 121 |
}
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
# --- 6. SEARCH API ENDPOINT ---
|
| 125 |
@app.get("/search")
|
| 126 |
async def search(q: str = Query(..., description="Search query"), background_tasks: BackgroundTasks = BackgroundTasks()):
|
|
|
|
| 7 |
from datetime import datetime, timedelta
|
| 8 |
from urllib.parse import urlparse
|
| 9 |
from fastapi import FastAPI, Query, BackgroundTasks
|
| 10 |
+
from fastapi.responses import JSONResponse, FileResponse # <--- FileResponse add kiya
|
| 11 |
from rapidfuzz import process, fuzz
|
| 12 |
from cryptography.fernet import Fernet
|
| 13 |
|
|
|
|
| 107 |
def ai_fallback_search(query: str):
|
| 108 |
return {
|
| 109 |
"ai_fallback_triggered": True,
|
| 110 |
+
"message": f"we dont find anything but we are trying to be the perfect sorry but our ai find this {query}",
|
| 111 |
"results": [
|
| 112 |
{
|
| 113 |
"url": f"https://www.google.com/search?q={query.replace(' ', '+')}",
|
|
|
|
| 120 |
]
|
| 121 |
}
|
| 122 |
|
| 123 |
+
# --- 0. SERVE HTML UI ---
|
| 124 |
+
@app.get("/")
|
| 125 |
+
async def serve_ui():
|
| 126 |
+
# Ye root URL (e.g. https://nebulixlabs-nutral-sr-image-enhancer.hf.space/) par HTML load karega
|
| 127 |
+
return FileResponse("index.html")
|
| 128 |
# --- 6. SEARCH API ENDPOINT ---
|
| 129 |
@app.get("/search")
|
| 130 |
async def search(q: str = Query(..., description="Search query"), background_tasks: BackgroundTasks = BackgroundTasks()):
|