open-webui/backend/apps/web/routers/utils.py

39 lines
813 B
Python
Raw Normal View History

2023-12-23 23:38:52 +00:00
from fastapi import APIRouter, UploadFile, File, BackgroundTasks
from fastapi import Depends, HTTPException, status
2024-03-02 08:33:20 +00:00
from starlette.responses import StreamingResponse, FileResponse
2023-12-23 23:38:52 +00:00
from pydantic import BaseModel
import requests
import os
2023-12-24 07:40:14 +00:00
import aiohttp
2023-12-23 23:38:52 +00:00
import json
2023-12-24 07:40:14 +00:00
2024-03-02 08:33:20 +00:00
from utils.utils import get_admin_user
from utils.misc import calculate_sha256, get_gravatar_url
2023-12-24 07:40:14 +00:00
2024-03-06 19:44:00 +00:00
from config import OLLAMA_BASE_URLS, DATA_DIR, UPLOAD_DIR
2024-01-09 21:25:42 +00:00
from constants import ERROR_MESSAGES
2023-12-23 23:38:52 +00:00
router = APIRouter()
@router.get("/gravatar")
async def get_gravatar(
email: str,
):
return get_gravatar_url(email)
2024-03-02 08:33:20 +00: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",
)