2023-12-23 15:38:52 -08:00
|
|
|
from fastapi import APIRouter, UploadFile, File, BackgroundTasks
|
|
|
|
|
from fastapi import Depends, HTTPException, status
|
2024-03-02 00:33:20 -08:00
|
|
|
from starlette.responses import StreamingResponse, FileResponse
|
|
|
|
|
|
2023-12-23 15:38:52 -08:00
|
|
|
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
import os
|
2023-12-23 23:40:14 -08:00
|
|
|
import aiohttp
|
2023-12-23 15:38:52 -08:00
|
|
|
import json
|
2023-12-23 23:40:14 -08:00
|
|
|
|
2024-03-02 00:33:20 -08:00
|
|
|
|
|
|
|
|
from utils.utils import get_admin_user
|
2024-01-26 21:38:33 -08:00
|
|
|
from utils.misc import calculate_sha256, get_gravatar_url
|
2023-12-23 23:40:14 -08:00
|
|
|
|
2024-03-06 11:44:00 -08:00
|
|
|
from config import OLLAMA_BASE_URLS, DATA_DIR, UPLOAD_DIR
|
2024-01-09 13:25:42 -08:00
|
|
|
from constants import ERROR_MESSAGES
|
|
|
|
|
|
2023-12-23 15:38:52 -08:00
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
2024-01-26 21:38:33 -08:00
|
|
|
@router.get("/gravatar")
|
|
|
|
|
async def get_gravatar(
|
|
|
|
|
email: str,
|
|
|
|
|
):
|
|
|
|
|
return get_gravatar_url(email)
|
2024-03-02 00:33:20 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/db/download")
|
|
|
|
|
async def download_db(user=Depends(get_admin_user)):
|
|
|
|
|
|
|
|
|
|
return FileResponse(
|
|
|
|
|
f"{DATA_DIR}/webui.db",
|
|
|
|
|
media_type="application/octet-stream",
|
|
|
|
|
filename="webui.db",
|
|
|
|
|
)
|