Spaces:
Running
Running
File size: 689 Bytes
7726a76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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")
@app.get("/")
async def read_root():
return FileResponse('index.html') # Your main HTML file
@app.get("/api/gemini-key")
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})
|