new data and api

This commit is contained in:
timothyafolami
2024-11-13 00:41:30 +01:00
parent 707b896826
commit d5cdeec299
10 changed files with 1293 additions and 2754 deletions
+12
View File
@@ -7,6 +7,7 @@ import uvicorn
from pydantic import BaseModel
from utils import product_categorizer
from social_media_collection import get_all_influencer_data
from names_collection import get_all_names
app = FastAPI()
@@ -47,8 +48,19 @@ async def influencers_data(request: InfluencerData):
return JSONResponse(content={"categorized_products": collected_data})
class CategoryInflencersData(BaseModel):
category: str
@app.post("/api/category-influencer-data")
async def category_influencers_data(request: CategoryInflencersData):
collected_data = get_all_names(request.category)
# extracting influencer names
influencer_names = collected_data[request.category]['names']
# now collecting the influencer data
collected_data = get_all_influencer_data(influencer_names, request.category)
return JSONResponse(content={"categorized_products": collected_data})
# Example of how to run the FastAPI server with Uvicorn
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8000)