File size: 1,658 Bytes
98caf15
 
 
 
1417758
98caf15
 
 
5974bb1
98caf15
 
 
 
 
 
 
 
23415c5
 
 
98caf15
 
 
 
 
 
 
 
 
 
 
 
ed15883
 
 
98caf15
 
 
 
1417758
98caf15
a2e26d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98caf15
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# main.py

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from huggingface_hub import login
from config import settings
from routers import tool_bpy_doc, tool_gpu_checker, tool_find_related, tool_wiki_search, tool_calls

login(settings.huggingface_key)

app = FastAPI(openapi_url="/api/v1/openapi.json",
              docs_url="/api/v1/docs")

app.add_middleware(
    CORSMiddleware,
    allow_origins=["https://projects.blender.org"],
    allow_methods=["GET", "POST"],
    allow_headers=["Authorization", "Content-Type"],
    allow_credentials=True,
)

app.include_router(
    tool_bpy_doc.router, prefix="/api/v1", tags=["Tools"])

app.include_router(
    tool_gpu_checker.router, prefix="/api/v1", tags=["Tools"])

app.include_router(
    tool_find_related.router, prefix="/api/v1", tags=["Tools"])

app.include_router(
    tool_wiki_search.router, prefix="/api/v1", tags=["Tools"])

app.include_router(
    tool_calls.router, prefix="/api/v1", tags=["Function Calls"])


@app.get("/", response_class=HTMLResponse)
async def root():
    return """
<!DOCTYPE html>
<html>
<head>
    <title>My Endpoints</title>
</head>
<body>
    <h1>Welcome to @mano-wii API</h1>
    <p>Click the button below to access the documentation:</p>
    <a href="/api/v1/docs" style="text-decoration: none;">
        <button style="padding: 10px 20px; background-color: #007BFF; color: #fff; border: none; cursor: pointer;">Go to Documentation</button>
    </a>
</body>
</html>
"""

app.mount("/api/v1/static", StaticFiles(directory="static"), name="static")