Srinivasulu kethanaboina commited on
Commit
4f7c970
1 Parent(s): c202a94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- from fastapi import FastAPI
3
  from fastapi.staticfiles import StaticFiles
4
  import uvicorn
5
 
@@ -18,7 +18,21 @@ chat = gr.ChatInterface(fn=respond_to_chat, title="Chat with AI")
18
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
19
 
20
  # Mount Gradio ChatInterface to FastAPI app
21
- app = gr.mount_gradio_app(app, chat,path="/gradio")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  # Run the app with uvicorn
24
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ from fastapi import FastAPI, Request, HTTPException
3
  from fastapi.staticfiles import StaticFiles
4
  import uvicorn
5
 
 
18
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
19
 
20
  # Mount Gradio ChatInterface to FastAPI app
21
+ app = gr.mount_gradio_app(app, chat, path="/gradio")
22
+
23
+ # Define the webhook endpoint
24
+ @app.post("/webhook")
25
+ async def webhook(request: Request):
26
+ data = await request.json()
27
+ username = data.get("username")
28
+ password = data.get("password")
29
+
30
+ if username == "your_username" and password == "your_password":
31
+ # Assuming you want to return or process the Gradio URL
32
+ gradio_url = "https://srinukethanaboina-srunu.hf.space/gradio"
33
+ return {"message": "Authenticated successfully", "gradio_url": gradio_url}
34
+ else:
35
+ raise HTTPException(status_code=401, detail="Unauthorized")
36
 
37
  # Run the app with uvicorn
38
  if __name__ == "__main__":