utils.py 813 Bytes
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
from fastapi import APIRouter, UploadFile, File, BackgroundTasks
from fastapi import Depends, HTTPException, status
3
4
from starlette.responses import StreamingResponse, FileResponse

Timothy J. Baek's avatar
Timothy J. Baek committed
5
6
7
8
9

from pydantic import BaseModel

import requests
import os
10
import aiohttp
Timothy J. Baek's avatar
Timothy J. Baek committed
11
import json
12

13
14

from utils.utils import get_admin_user
15
from utils.misc import calculate_sha256, get_gravatar_url
16

17
from config import OLLAMA_BASE_URLS, DATA_DIR, UPLOAD_DIR
Timothy J. Baek's avatar
Timothy J. Baek committed
18
19
from constants import ERROR_MESSAGES

Timothy J. Baek's avatar
Timothy J. Baek committed
20
21
22
23

router = APIRouter()


24
25
26
27
28
@router.get("/gravatar")
async def get_gravatar(
    email: str,
):
    return get_gravatar_url(email)
29
30
31
32
33
34
35
36
37
38


@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",
    )