youngtsai commited on
Commit
8692287
·
1 Parent(s): d3658c3

with gr.Row(visible=False) as admin_group:

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -661,7 +661,6 @@ def init_params(request: gr.Request):
661
  english_group = gr.update(visible=True)
662
  chinese_group = gr.update(visible=True)
663
 
664
-
665
  # check if origin is from junyiacademy
666
  query_params = dict(request.query_params)
667
  request_origin = request.headers.get("origin", "").replace("https://", "").replace("http://", "")
@@ -671,9 +670,8 @@ def init_params(request: gr.Request):
671
  "junyiacademy.appspot.com",
672
  "colearn30.com", # 樂寫網
673
  "hf.space",
674
- "localhost:7860"
675
  ]
676
- if any(allowed_origin in request_origin for allowed_origin in allowed_request_origins):
677
  pass
678
  else:
679
  raise gr.Error("Invalid origin")
@@ -688,7 +686,6 @@ def init_params(request: gr.Request):
688
  english_group = gr.update(visible=False)
689
  chinese_group = gr.update(visible=True)
690
 
691
-
692
  return request_origin, english_group, chinese_group
693
 
694
  def update_english_grapragh_practice_rows(selected_tab):
@@ -770,7 +767,7 @@ english_exam_practice_tab_button_js = """
770
 
771
  with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary_hue=gr.themes.colors.orange), css=CSS) as demo:
772
 
773
- with gr.Row(visible=True) as admin_group:
774
  user_data = gr.Textbox(label="User Data", value="")
775
  request_origin = gr.Textbox(label="Request Domain", value="")
776
 
 
661
  english_group = gr.update(visible=True)
662
  chinese_group = gr.update(visible=True)
663
 
 
664
  # check if origin is from junyiacademy
665
  query_params = dict(request.query_params)
666
  request_origin = request.headers.get("origin", "").replace("https://", "").replace("http://", "")
 
670
  "junyiacademy.appspot.com",
671
  "colearn30.com", # 樂寫網
672
  "hf.space",
 
673
  ]
674
+ if any(allowed_origin in request_origin for allowed_origin in allowed_request_origins) or is_env_local:
675
  pass
676
  else:
677
  raise gr.Error("Invalid origin")
 
686
  english_group = gr.update(visible=False)
687
  chinese_group = gr.update(visible=True)
688
 
 
689
  return request_origin, english_group, chinese_group
690
 
691
  def update_english_grapragh_practice_rows(selected_tab):
 
767
 
768
  with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary_hue=gr.themes.colors.orange), css=CSS) as demo:
769
 
770
+ with gr.Row(visible=False) as admin_group:
771
  user_data = gr.Textbox(label="User Data", value="")
772
  request_origin = gr.Textbox(label="Request Domain", value="")
773