Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from utils.logging_utils import setup_logging
|
| 2 |
from scripts.train_viral_potential import train_viral_potential
|
| 3 |
from scripts.train_engagement_rate import train_engagement_rate
|
|
@@ -9,18 +10,27 @@ from scripts.analyze_engagement import analyze_engagement
|
|
| 9 |
# Set up logging
|
| 10 |
setup_logging()
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
train_viral_potential()
|
| 16 |
train_engagement_rate()
|
| 17 |
train_promotion_strategy()
|
| 18 |
train_time_series()
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
analyze_engagement()
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
caption
|
| 26 |
-
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
from utils.logging_utils import setup_logging
|
| 3 |
from scripts.train_viral_potential import train_viral_potential
|
| 4 |
from scripts.train_engagement_rate import train_engagement_rate
|
|
|
|
| 10 |
# Set up logging
|
| 11 |
setup_logging()
|
| 12 |
|
| 13 |
+
# Initialize FastAPI app
|
| 14 |
+
app = FastAPI()
|
| 15 |
+
|
| 16 |
+
@app.get("/")
|
| 17 |
+
def read_root():
|
| 18 |
+
return {"message": "Instagram AI Backend"}
|
| 19 |
+
|
| 20 |
+
@app.post("/train-models")
|
| 21 |
+
def train_models():
|
| 22 |
train_viral_potential()
|
| 23 |
train_engagement_rate()
|
| 24 |
train_promotion_strategy()
|
| 25 |
train_time_series()
|
| 26 |
+
return {"message": "Models trained successfully"}
|
| 27 |
|
| 28 |
+
@app.post("/analyze-engagement")
|
| 29 |
+
def analyze_engagement_endpoint():
|
| 30 |
analyze_engagement()
|
| 31 |
+
return {"message": "Engagement analysis completed"}
|
| 32 |
|
| 33 |
+
@app.post("/analyze-image")
|
| 34 |
+
def analyze_image_endpoint(image_url: str, caption: str):
|
| 35 |
+
analyze_image_url(image_url, caption)
|
| 36 |
+
return {"message": "Image analysis completed"}
|