new data and api
This commit is contained in:
+12
@@ -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)
|
||||
Reference in New Issue
Block a user