Spaces:
Runtime error
Runtime error
File size: 1,068 Bytes
b6e5a27 c8fa3bd ae9d4c8 c8fa3bd 6505613 c8fa3bd 6505613 c8fa3bd 6505613 c8fa3bd 6505613 c8fa3bd 6505613 b6e5a27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from backend.app.routes import search_route
import logging
# Initialize FastAPI app
app = FastAPI(title="LeetCode Vector Search API", version="1.0")
# Set up logging
logging.basicConfig(level=logging.INFO)
# Configure CORS
app.add_middleware(
CORSMiddleware,
# Replace with frontend URLs in production
allow_origins=["https://leet-search-sepia.vercel.app/search",
"https://leet-search-sepia.vercel.app", "http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Health check endpoint
@app.get("/")
def root():
return {"message": "LeetCode Vector Search API is running 🚀"}
# Register routes
app.include_router(search_route.router, prefix="/api", tags=["Search"])
# run initial population of the database only once then only run scraping
# populate_db()
if __name__ == "__main__":
uvicorn.run("backend.app.main:app", host="0.0.0.0",
port=7860, reload=False)
|