-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
23 lines (19 loc) · 671 Bytes
/
Copy pathapp.py
File metadata and controls
23 lines (19 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# imports
import os
import logging
from dotenv import load_dotenv
from fastapi import FastAPI, HTTPException
from mlflow.exceptions import MlflowException
# local absolute imports
from src.api.model import NewsClassifier
from src.api.endpoints import get_prediction, train_and_deploy
from run_ml import run_training
app = FastAPI(
title="News classifier API",
description="Classifies news titles into 4 distinct categories.",
version="0.1",
debug=True
)
app.add_api_route("/predict", get_prediction, methods=["POST"])
app.add_api_route("/train_and_deploy", train_and_deploy, methods=["GET"])
app.add_api_route("/", lambda: app.title, methods=["GET"])