growth-Mindset / app.py
mobenta's picture
Rename gemini.py to app.py
7726a76 verified
raw
history blame contribute delete
689 Bytes
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})