Fred808 commited on
Commit
4e1cf33
·
verified ·
1 Parent(s): 68f1b21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -39,9 +39,18 @@ class AnalyzePostRequest(BaseModel):
39
  hashtags: str
40
  image_url: str
41
 
 
 
 
 
 
42
  RATE_LIMIT_DELAY = 5 # Delay in seconds between API calls
43
  LAST_REQUEST_TIME = 0
44
 
 
 
 
 
45
  @app.post("/fetch-posts")
46
  async def fetch_posts(user: UserRequest):
47
  """
 
39
  hashtags: str
40
  image_url: str
41
 
42
+ # Configure logging
43
+ logging.basicConfig(level=logging.INFO)
44
+ logger = logging.getLogger(__name__)
45
+
46
+ # Rate limiting variables
47
  RATE_LIMIT_DELAY = 5 # Delay in seconds between API calls
48
  LAST_REQUEST_TIME = 0
49
 
50
+ # Pydantic model for request validation
51
+ class UserRequest(BaseModel):
52
+ username: constr(min_length=1, max_length=30, regex="^[a-zA-Z0-9._]+$") # Instagram username format
53
+
54
  @app.post("/fetch-posts")
55
  async def fetch_posts(user: UserRequest):
56
  """