Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import uvicorn
|
| 2 |
from fastapi import FastAPI, Depends
|
| 3 |
from starlette.responses import RedirectResponse
|
|
@@ -9,6 +10,9 @@ from starlette.config import Config
|
|
| 9 |
import gradio as gr
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
load_dotenv()
|
| 13 |
app = FastAPI()
|
| 14 |
|
|
@@ -68,7 +72,11 @@ async def auth(request: Request):
|
|
| 68 |
return RedirectResponse(url='/gradio')
|
| 69 |
|
| 70 |
with gr.Blocks() as login_demo:
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
_js_redirect = """
|
| 73 |
() => {
|
| 74 |
url = '/login' + window.location.search;
|
|
@@ -87,7 +95,9 @@ with gr.Blocks() as main_demo:
|
|
| 87 |
gr.Button("Logout", link="/logout")
|
| 88 |
main_demo.load(greet, None, m)
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
|
| 93 |
if __name__ == '__main__':
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
import uvicorn
|
| 3 |
from fastapi import FastAPI, Depends
|
| 4 |
from starlette.responses import RedirectResponse
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
|
| 13 |
+
from app import build_securely
|
| 14 |
+
from ui import render_logo
|
| 15 |
+
|
| 16 |
load_dotenv()
|
| 17 |
app = FastAPI()
|
| 18 |
|
|
|
|
| 72 |
return RedirectResponse(url='/gradio')
|
| 73 |
|
| 74 |
with gr.Blocks() as login_demo:
|
| 75 |
+
render_logo()
|
| 76 |
+
with gr.Row():
|
| 77 |
+
gr.Column()
|
| 78 |
+
btn = gr.Button("Login", variant="huggingface")
|
| 79 |
+
gr.Column()
|
| 80 |
_js_redirect = """
|
| 81 |
() => {
|
| 82 |
url = '/login' + window.location.search;
|
|
|
|
| 95 |
gr.Button("Logout", link="/logout")
|
| 96 |
main_demo.load(greet, None, m)
|
| 97 |
|
| 98 |
+
sheami_app = asyncio.run(build_securely())
|
| 99 |
+
|
| 100 |
+
app = gr.mount_gradio_app(app, sheami_app, path="/gradio", auth_dependency=get_user)
|
| 101 |
|
| 102 |
|
| 103 |
if __name__ == '__main__':
|