File size: 766 Bytes
dbaf7c6
 
b090190
dbaf7c6
414dfdc
dbaf7c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b090190
 
dbaf7c6
414dfdc
 
 
 
 
 
 
dbaf7c6
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
from fastapi import Depends, FastAPI, Header, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import RedirectResponse
from routers import tokenize
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():
    response = RedirectResponse(url='/docs')
    return response

@app.get("/version")
def version():
    """
    Get PyThaiNLP Version
    """
    return {"version": pythainlp.__version__}

app.include_router(tokenize.router, prefix="/tokenize", tags=["Tokenize"])