abidlabs HF staff commited on
Commit
d5f56c9
·
1 Parent(s): 916829e
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +5 -14
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -37,14 +37,10 @@ def get_user(request: Request):
37
  @app.get('/')
38
  def public(request: Request, user: dict = Depends(get_user)):
39
  root_url = gr.route_utils.get_root_url(request, "/", None)
40
- print("root_url", root_url)
41
- return RedirectResponse(url=f'{root_url}/main/')
42
- # if user:
43
- # return RedirectResponse(url=f"{root_url}/gradio")
44
- # else:
45
- # redirect_url = f"{root_url}/login-demo"
46
- # print("Redirecting to", redirect_url)
47
- # return RedirectResponse(url=redirect_url)
48
 
49
  @app.route('/logout')
50
  async def logout(request: Request):
@@ -74,16 +70,11 @@ with gr.Blocks() as login_demo:
74
  _js_redirect = """
75
  () => {
76
  url = '/login' + window.location.search;
77
- if ( window !== window.parent ) {
78
- window.open(url, '_blank');
79
- } else {
80
- window.location.assign(url);
81
- }
82
  }
83
  """
84
  btn.click(None, js=_js_redirect)
85
 
86
-
87
  app = gr.mount_gradio_app(app, login_demo, path="/main")
88
 
89
  def greet(request: gr.Request):
 
37
  @app.get('/')
38
  def public(request: Request, user: dict = Depends(get_user)):
39
  root_url = gr.route_utils.get_root_url(request, "/", None)
40
+ if user:
41
+ return RedirectResponse(url=f'{root_url}/main/')
42
+ else:
43
+ return RedirectResponse(url=f'{root_url}/gradio/')
 
 
 
 
44
 
45
  @app.route('/logout')
46
  async def logout(request: Request):
 
70
  _js_redirect = """
71
  () => {
72
  url = '/login' + window.location.search;
73
+ window.open(url, '_blank');
 
 
 
 
74
  }
75
  """
76
  btn.click(None, js=_js_redirect)
77
 
 
78
  app = gr.mount_gradio_app(app, login_demo, path="/main")
79
 
80
  def greet(request: gr.Request):