|
|
|
|
|
|
|
|
import os |
|
|
import sys |
|
|
from fastapi import FastAPI |
|
|
from fastapi.responses import HTMLResponse |
|
|
from fastapi.staticfiles import StaticFiles |
|
|
|
|
|
|
|
|
try: |
|
|
import python_multipart |
|
|
except ImportError: |
|
|
print("Warning: python-multipart is not installed. File uploads may fail.") |
|
|
|
|
|
from routes import auth, api_keys, proxies, admin |
|
|
|
|
|
|
|
|
|
|
|
conda_prefix = os.environ.get("CONDA_PREFIX") |
|
|
if conda_prefix: |
|
|
expected_python_path = os.path.join(conda_prefix, "bin", "python") |
|
|
if sys.executable != expected_python_path: |
|
|
print(f"Warning: Python interpreter is not from the expected Conda environment 'airs'.") |
|
|
print(f"Expected: {expected_python_path}") |
|
|
print(f"Actual: {sys.executable}") |
|
|
|
|
|
|
|
|
else: |
|
|
print("Warning: CONDA_PREFIX environment variable not set. Cannot verify Conda environment.") |
|
|
|
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static") |
|
|
|
|
|
|
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"]) |
|
|
app.include_router(api_keys.router, prefix="/api/user", tags=["api_keys"]) |
|
|
app.include_router(proxies.router, prefix="/api/proxies", tags=["proxies"]) |
|
|
app.include_router(admin.router, prefix="/api/admin", tags=["admin"]) |
|
|
|
|
|
|
|
|
@app.get("/", response_class=HTMLResponse) |
|
|
async def read_root(): |
|
|
with open("static/index.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/login", response_class=HTMLResponse) |
|
|
async def read_login(): |
|
|
with open("static/login.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/reset-password", response_class=HTMLResponse) |
|
|
async def read_reset_password(): |
|
|
with open("static/reset-password.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/signup", response_class=HTMLResponse) |
|
|
async def read_signup(): |
|
|
with open("static/signup.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/admin", response_class=HTMLResponse) |
|
|
async def read_admin(): |
|
|
with open("static/admin.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/admin/users", response_class=HTMLResponse) |
|
|
async def read_admin_users(): |
|
|
with open("static/admin/users.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/static/components/admin_navbar.html", response_class=HTMLResponse) |
|
|
async def get_admin_navbar(): |
|
|
with open("static/components/admin_navbar.html", "r") as f: |
|
|
return f.read() |
|
|
|
|
|
@app.get("/admin/pictures", response_class=HTMLResponse) |
|
|
async def read_admin_pictures(): |
|
|
with open("static/admin/pictures.html", "r") as f: |
|
|
return f.read() |
|
|
|