Fred808 commited on
Commit
7663068
·
verified ·
1 Parent(s): 67fb690

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
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
- # Main application logic
13
- if __name__ == "__main__":
14
- # Train models
 
 
 
 
 
 
15
  train_viral_potential()
16
  train_engagement_rate()
17
  train_promotion_strategy()
18
  train_time_series()
 
19
 
20
- # Analyze engagement data
 
21
  analyze_engagement()
 
22
 
23
- # Analyze an example image
24
- image_url = "https://example.com/path/to/image.jpg"
25
- caption = "This is a beautiful sunset!"
26
- analyze_image_url(image_url, caption)
 
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"}