Spaces:
Sleeping
Sleeping
File size: 1,183 Bytes
d92c861 54db18f be531b6 54db18f d92c861 ae5f2f2 005c659 07fe890 d92c861 2729551 ae5f2f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from fastapi import FastAPI, File, UploadFile, HTTPException
from fastapi.responses import HTMLResponse
from fastapi.responses import StreamingResponse
from fastapi.responses import FileResponse
from fastapi.middleware.cors import CORSMiddleware
from io import StringIO
import os
import uuid,requests
import data_collector as dc
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# main
data,message = dc.get_data(b_id=637,product_name = "RS 10 TOFFEE")
print(message)
@app.post("/get_image_for_text")
async def get_image_for_text(b_id:int,product_name:str):
# main
data,message = dc.get_data(b_id = b_id , product_name = product_name)
if message=="done":
# Summarize the sales count per month
data['transaction_date'] = pd.to_datetime(data['transaction_date'])
data.set_index('transaction_date', inplace=True)
monthly_sales = data['sell_qty'].resample('M').sum().reset_index()
full_trend,forecasted_value,rounded_value = forecast(monthly_sales)
print(full_trend,forecasted_value,rounded_value)
return rounded_value |