forked from code-kern-ai/bricks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
52 lines (44 loc) · 1.33 KB
/
api.py
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
import classifiers
import extractors
import generators
from extractors.util.spacy import download_all_models
api = FastAPI()
origins = [
"http://127.0.0.1",
"http://127.0.0.1:3000",
"http://127.0.0.1:3001",
"http://localhost",
"http://localhost:4455",
"http://localhost:3000",
"http://localhost:3001",
"http://localhost:8000",
"https://bricks.kern.ai",
]
api.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@api.get("/")
async def root():
html_content = """
<html>
<head>
<title>Kern AI - Bricks</title>
</head>
<body>
<h1>Endpoints for <a href="https://kern.ai" target="_blank">Kern AI</a> bricks</h1>
<p>Please look into bricks to see how to use these endpoints.</p>
</body>
</html>
"""
return HTMLResponse(content=html_content, status_code=200)
api.include_router(classifiers.router, prefix="/classifiers", tags=["classifiers"])
api.include_router(extractors.router, prefix="/extractors", tags=["extractors"])
api.include_router(generators.router, prefix="/generators", tags=["generators"])
download_all_models()