Spaces:
Runtime error
Runtime error
Download app.py from scholar-engine/ai-note-manager: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/scholar-engine/ai-note-manager/resolve/main/app.py
- Command line
-
hf download hf://spaces/scholar-engine/ai-note-manager/app.py
-
curl -L -o app.py https://huggingface.co/spaces/scholar-engine/ai-note-manager/resolve/main/app.py
1.03 kB
| import os | |
| from fastapi import FastAPI, Depends, HTTPException, status | |
| from fastapi.security import APIKeyHeader | |
| from src.services import summarize_note, assign_tag, analyze_sentiment | |
| app = FastAPI() | |
| API_KEY_NAME = "X-API-KEY" | |
| API_KEY = os.environ.get("API_KEY") | |
| api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False) | |
| async def get_api_key(api_key: str = Depends(api_key_header)): | |
| print(f"Received API Key: {api_key}") | |
| print(f"Expected API Key from environment: {API_KEY}") | |
| # if api_key != API_KEY: | |
| # raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid API Key") | |
| return api_key | |
| def health_check(): | |
| return {"status": "ok"} | |
| def analyze_note(note_data: dict, api_key: str = Depends(get_api_key)): | |
| summary = summarize_note(note_data) | |
| tag = assign_tag(note_data) | |
| sentiment = analyze_sentiment(note_data) | |
| return { | |
| "summary": summary, | |
| "tag": tag, | |
| "sentiment": sentiment | |
| } |