Spaces:
Running
Running
| Copy | |
| import os | |
| from fastapi import FastAPI, HTTPException | |
| from fastapi.responses import FileResponse, JSONResponse | |
| from fastapi.staticfiles import StaticFiles | |
| app = FastAPI() | |
| # Serve static files if you have any | |
| app.mount("/static", StaticFiles(directory="static"), name="static") | |
| async def read_root(): | |
| return FileResponse('index.html') # Your main HTML file | |
| async def get_gemini_key(): | |
| # Get API key from environment variable (set in Space settings) | |
| api_key = os.environ.get("GEMINI_KEY") | |
| if not api_key: | |
| return JSONResponse({"error": "API key not found"}, status_code=404) | |
| return JSONResponse({"key": api_key}) | |