Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException,Query
|
| 2 |
+
from supabase import create_client, Client
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
url: str = os.getenv('SUPABASE_URL')
|
| 8 |
+
key: str = os.getenv('SUPABASE_KEY')
|
| 9 |
+
supabase: Client = create_client(url, key)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@app.get('/get_hotel_data')
|
| 13 |
+
async def get_hotel_data(hushh_id:str):
|
| 14 |
+
hotel_brand_frequency = {}
|
| 15 |
+
result = {}
|
| 16 |
+
resp = supabase.table("receipt_radar_structured_data_duplicate").select("brand,message_id,company,logo").eq("brand_category","Travel").execute()
|
| 17 |
+
for ds in resp.data:
|
| 18 |
+
if ds.get('brand'):
|
| 19 |
+
result[ds.get('brand')] = {"message_id":ds.get('message_id'),"domain":ds.get('company'),"hotel_logo":ds.get('logo')}
|
| 20 |
+
# if arrival_city:
|
| 21 |
+
if ds.get('brand') in hotel_brand_frequency:
|
| 22 |
+
hotel_brand_frequency[ds.get('brand')] += 1
|
| 23 |
+
else:
|
| 24 |
+
hotel_brand_frequency[ds.get('brand')] = 1
|
| 25 |
+
|
| 26 |
+
result['hotel_brand_frequency'] = hotel_brand_frequency
|
| 27 |
+
return result
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|