Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI, Request
|
|
|
|
| 2 |
import uvicorn
|
| 3 |
|
| 4 |
# Initialize FastAPI app
|
|
@@ -11,10 +12,42 @@ async def whatsapp_webhook(request: Request):
|
|
| 11 |
print(f"Received data: {data}") # Log incoming data for debugging
|
| 12 |
return {"status": "success", "received_data": data}
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Run the FastAPI app with Uvicorn
|
| 15 |
if __name__ == "__main__":
|
| 16 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
#!/usr/bin/env python
|
| 19 |
# coding: utf-8
|
| 20 |
|
|
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
+
import gradio as gr
|
| 3 |
import uvicorn
|
| 4 |
|
| 5 |
# Initialize FastAPI app
|
|
|
|
| 12 |
print(f"Received data: {data}") # Log incoming data for debugging
|
| 13 |
return {"status": "success", "received_data": data}
|
| 14 |
|
| 15 |
+
# Create a simple Gradio Blocks interface
|
| 16 |
+
def greet(name):
|
| 17 |
+
return f"Hello, {name}!"
|
| 18 |
+
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
gr.Markdown("### Greeting App")
|
| 21 |
+
name_input = gr.Textbox(placeholder="Enter your name")
|
| 22 |
+
greet_button = gr.Button("Greet")
|
| 23 |
+
output_text = gr.Textbox(label="Greeting")
|
| 24 |
+
|
| 25 |
+
greet_button.click(fn=greet, inputs=name_input, outputs=output_text)
|
| 26 |
+
|
| 27 |
+
# Mount the Gradio app at "/gradio"
|
| 28 |
+
app.mount("/gradio", demo)
|
| 29 |
+
|
| 30 |
# Run the FastAPI app with Uvicorn
|
| 31 |
if __name__ == "__main__":
|
| 32 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 33 |
|
| 34 |
+
# from fastapi import FastAPI, Request
|
| 35 |
+
# import uvicorn
|
| 36 |
+
|
| 37 |
+
# # Initialize FastAPI app
|
| 38 |
+
# app = FastAPI()
|
| 39 |
+
|
| 40 |
+
# # FastAPI route to handle WhatsApp webhook
|
| 41 |
+
# @app.post("/whatsapp-webhook")
|
| 42 |
+
# async def whatsapp_webhook(request: Request):
|
| 43 |
+
# data = await request.json() # Parse incoming JSON data
|
| 44 |
+
# print(f"Received data: {data}") # Log incoming data for debugging
|
| 45 |
+
# return {"status": "success", "received_data": data}
|
| 46 |
+
|
| 47 |
+
# # Run the FastAPI app with Uvicorn
|
| 48 |
+
# if __name__ == "__main__":
|
| 49 |
+
# uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 50 |
+
|
| 51 |
#!/usr/bin/env python
|
| 52 |
# coding: utf-8
|
| 53 |
|