File size: 986 Bytes
0ffbeb2
 
3fe739b
 
 
2c8f1fd
3fe739b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ffbeb2
 
3fe739b
 
 
 
 
0ffbeb2
 
 
 
 
 
 
 
 
 
 
3fe739b
 
 
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
import os

import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.hf import get_dir


app = FastAPI()
# for CORS
origins = ['http://localhost:3000', 'http://localhost:5173', 'http://localhost:5174']

# middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins = origins,
    allow_credentials = True,
    allow_methods = ['*'],
    allow_headers = ['*']
)

@app.get("/")
async def root():
    current_dir = os.getcwd()
    return {"message": "Hello World", "dir": current_dir}

@app.get("/book")
async def root():
    return {"book_name": "Hikayat Naga Terbang"}

# @app.post('/classify')
# async def classify_text(question:str):
#     answer = generate_response(question)
#     topic_label, score = answer
#
#     return {"label": topic_label}
@app.get('/hf-dir')
def get_hf_dir():
    return {
        "hf_dir": get_dir()
    }

if __name__ == '__main__':
    uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)