-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (21 loc) · 641 Bytes
/
main.py
File metadata and controls
33 lines (21 loc) · 641 Bytes
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
from fastapi import FastAPI
from mylib.script import wiki, search_wiki, phrase
import uvicorn
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Wikipedia API. Call /search or /find-wiki"}
@app.get("/search/{name}")
def search_wikipedia(name: str):
result = search_wiki(name)
return {"result": result}
@app.get("/find-wiki/{value}")
def my_wiki(value: str):
result = wiki(value)
return {"result": result}
@app.get("/phrases/{value}")
def phrases(value: str):
result = phrase(value)
return {"result": result}
if __name__ == "__main__":
uvicorn.run(app, port=8080, host="0.0.0.0")