Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 1.2 KB

You have to be logged in to leave a comment. Sign In
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
45
46
47
48
49
50
51
52
53
54
  1. from src.toxic.pipeline.train_pipeline import TrainingPipeline
  2. from fastapi import FastAPI
  3. import uvicorn
  4. import sys
  5. from fastapi.templating import Jinja2Templates
  6. from starlette.responses import RedirectResponse
  7. from fastapi.responses import Response
  8. # from src.toxic.pipeline.prediction_pipeline import PredictionPipeline
  9. from src.toxic.constants import *
  10. from src.toxic import logger
  11. text:str = "What is machine learing?"
  12. app = FastAPI()
  13. @app.get("/", tags=["authentication"])
  14. async def index():
  15. return RedirectResponse(url="/docs")
  16. @app.get("/train")
  17. async def training():
  18. try:
  19. train_pipeline = TrainingPipeline()
  20. train_pipeline.run_pipeline()
  21. return Response("Training successful !!")
  22. except Exception as e:
  23. return Response(f"Error Occurred! {e}")
  24. # @app.post("/predict")
  25. # async def predict_route(text):
  26. # try:
  27. # obj = PredictionPipeline()
  28. # text = obj.run_pipeline(text)
  29. # return text
  30. # except Exception as e:
  31. # raise CustomException(e, sys) from e
  32. if __name__=="__main__":
  33. uvicorn.run(app, host=APP_HOST, port=APP_PORT)
  34. # obj = TrainingPipeline()
  35. # obj.run_pipeline()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...