Omkar008's picture
Create app.py
5db7441 verified
raw
history blame
985 Bytes
from fastapi import FastAPI, HTTPException,Query
from supabase import create_client, Client
app = FastAPI()
url: str = os.getenv('SUPABASE_URL')
key: str = os.getenv('SUPABASE_KEY')
supabase: Client = create_client(url, key)
@app.get('/get_hotel_data')
async def get_hotel_data(hushh_id:str):
hotel_brand_frequency = {}
result = {}
resp = supabase.table("receipt_radar_structured_data_duplicate").select("brand,message_id,company,logo").eq("brand_category","Travel").execute()
for ds in resp.data:
if ds.get('brand'):
result[ds.get('brand')] = {"message_id":ds.get('message_id'),"domain":ds.get('company'),"hotel_logo":ds.get('logo')}
# if arrival_city:
if ds.get('brand') in hotel_brand_frequency:
hotel_brand_frequency[ds.get('brand')] += 1
else:
hotel_brand_frequency[ds.get('brand')] = 1
result['hotel_brand_frequency'] = hotel_brand_frequency
return result