-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (22 loc) · 769 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
import json
import uuid
from datetime import datetime
import uvicorn
from fastapi import FastAPI
from src.model import Tweeter, TweeterFactory
app = FastAPI()
tweeter: Tweeter = TweeterFactory.create_instance()
@app.get("/")
async def root():
return {"message": "Welcome to auto tweet generator API"}
@app.get("/tweet")
async def predict():
response: dict[str, str] = dict({"timestamp": str(datetime.now()),
"response_id": str(uuid.uuid4()),
"tweet": tweeter.tweet()})
return json.dumps(response)
@app.get("/health")
async def health():
return {"message": "Congratulations, I am healthy :) "}
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8000)