nagasurendra commited on
Commit
fd268aa
·
verified ·
1 Parent(s): e738758

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import bcrypt
2
  import gradio as gr
3
  from simple_salesforce import Salesforce
 
4
 
5
  # Salesforce Connection
6
  sf = Salesforce(username='diggavalli98@gmail.com', password='Sati@1020', security_token='sSSjyhInIsUohKpG8sHzty2q')
7
 
 
 
 
8
  # Cart Array to Store Items
9
  cart = []
10
 
@@ -207,7 +211,7 @@ def modal_js():
207
  return modal_script
208
 
209
  # Gradio App
210
- with gr.Blocks() as app:
211
  with gr.Row():
212
  gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
213
 
@@ -261,4 +265,18 @@ with gr.Blocks() as app:
261
 
262
  preference.change(lambda pref: filter_menu(pref), [preference], menu_output)
263
 
264
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import bcrypt
2
  import gradio as gr
3
  from simple_salesforce import Salesforce
4
+ from fastapi import FastAPI, Request
5
 
6
  # Salesforce Connection
7
  sf = Salesforce(username='diggavalli98@gmail.com', password='Sati@1020', security_token='sSSjyhInIsUohKpG8sHzty2q')
8
 
9
+ # FastAPI App for Backend
10
+ app = FastAPI()
11
+
12
  # Cart Array to Store Items
13
  cart = []
14
 
 
211
  return modal_script
212
 
213
  # Gradio App
214
+ with gr.Blocks() as gradio_app:
215
  with gr.Row():
216
  gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
217
 
 
265
 
266
  preference.change(lambda pref: filter_menu(pref), [preference], menu_output)
267
 
268
+ # FastAPI Endpoint for Adding to Cart
269
+ @app.post("/add_to_cart")
270
+ async def add_to_cart_endpoint(request: Request):
271
+ data = await request.json()
272
+ name = data["name"]
273
+ price = data["price"]
274
+ addons = data["addons"]
275
+ instructions = data["instructions"]
276
+ quantity = data["quantity"]
277
+
278
+ response_message = add_to_cart(name, price, addons, instructions, quantity)
279
+ return {"message": response_message}
280
+
281
+ # Launch Gradio App with FastAPI
282
+ app.mount("/", gradio_app)