new data added
This commit is contained in:
+20
-2
@@ -3,9 +3,10 @@ from fastapi import FastAPI, Form, Body
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from typing import List, Dict
|
||||
import uvicorn
|
||||
from pydantic import BaseModel
|
||||
from utils import product_categorizer
|
||||
|
||||
from social_media_collection import get_all_influencer_data
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@@ -30,7 +31,24 @@ app.add_middleware(
|
||||
class ProductRequest(BaseModel):
|
||||
products: List[str]
|
||||
|
||||
@app.post("/categorize-products/")
|
||||
@app.post("/api/categorize-products/")
|
||||
async def categorize_products(request: ProductRequest):
|
||||
categorized_output = product_categorizer(request.products)
|
||||
return JSONResponse(content={"categorized_products": categorized_output})
|
||||
|
||||
|
||||
class InfluencerData(BaseModel):
|
||||
influencer_names: List[str]
|
||||
category : str
|
||||
|
||||
@app.post("/api/influencer-data/")
|
||||
async def influencers_data(request: InfluencerData):
|
||||
collected_data = get_all_influencer_data(request.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