Spaces:
Runtime error
Runtime error
Download app/api/pages/function.py from swifttoken/grok2api-hf: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/swifttoken/grok2api-hf/resolve/main/app/api/pages/function.py
- Command line
-
hf download hf://spaces/swifttoken/grok2api-hf/app/api/pages/function.py
-
curl -L -o function.py https://huggingface.co/spaces/swifttoken/grok2api-hf/resolve/main/app/api/pages/function.py
2.17 kB
| from pathlib import Path | |
| from fastapi import APIRouter, HTTPException | |
| from fastapi.responses import FileResponse, RedirectResponse | |
| from app.core.auth import is_function_enabled | |
| router = APIRouter() | |
| STATIC_DIR = Path(__file__).resolve().parents[3] / "_public" / "static" | |
| def _function_page_response(relative_path: str) -> FileResponse: | |
| file_path = STATIC_DIR / relative_path | |
| if not file_path.exists(): | |
| raise HTTPException(status_code=404, detail="Page not found") | |
| return FileResponse(file_path) | |
| async def root(): | |
| if is_function_enabled(): | |
| return RedirectResponse(url="/login") | |
| return RedirectResponse(url="/admin/login") | |
| async def function_login(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/login.html") | |
| async def function_imagine(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/imagine.html") | |
| async def function_imagine_lab(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/imagine-lab.html") | |
| async def function_voice(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/voice.html") | |
| async def function_video(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/video.html") | |
| async def function_chat(): | |
| if not is_function_enabled(): | |
| raise HTTPException(status_code=404, detail="Not Found") | |
| return _function_page_response("function/pages/chat.html") | |