-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
37 lines (28 loc) · 882 Bytes
/
main.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
# -*- coding: utf-8 -*-
from fastapi import Depends, FastAPI, Header, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from routers import tag, tokenize, word_vector
import uvicorn
import pythainlp
DESC_TEXT = "Pythainlp API"
app = FastAPI(
title='Pythainlp API',
description=DESC_TEXT,
version='0.1',
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def index():
return {"Pythainlp Version": pythainlp.__version__}
app.include_router(tag.router, prefix="/tag", tags=["Tag"])
app.include_router(tokenize.router, prefix="/tokenize", tags=["Tokenize"])
app.include_router(word_vector.router,
prefix="/word-vector", tags=["Word Vector"])
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)