Spaces:
Sleeping
Sleeping
update init_params
Browse files
app.py
CHANGED
|
@@ -3,53 +3,11 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
# --- Init params ---
|
| 5 |
def init_params(text, request: gr.Request):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
print("Query parameters:", dict(request.query_params))
|
| 10 |
-
# url = request.url
|
| 11 |
-
print("Request URL:", request.url)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
password_text = ""
|
| 15 |
-
admin = gr.update(visible=True)
|
| 16 |
-
reading_passage_admin = gr.update(visible=True)
|
| 17 |
-
summary_admin = gr.update(visible=True)
|
| 18 |
-
see_detail = gr.update(visible=True)
|
| 19 |
-
worksheet_accordion = gr.update(visible=True)
|
| 20 |
-
lesson_plan_accordion = gr.update(visible=True)
|
| 21 |
-
exit_ticket_accordion = gr.update(visible=True)
|
| 22 |
-
|
| 23 |
-
chatbot_open_ai_streaming = gr.update(visible=False)
|
| 24 |
-
chatbot_ai = gr.update(visible=False)
|
| 25 |
-
ai_chatbot_params = gr.update(visible=True)
|
| 26 |
-
|
| 27 |
-
is_env_prod = gr.update(value=False)
|
| 28 |
-
|
| 29 |
-
# if youtube_link in query_params
|
| 30 |
-
if "youtube_id" in request.query_params:
|
| 31 |
-
youtube_id = request.query_params["youtube_id"]
|
| 32 |
-
youtube_link = f"https://www.youtube.com/watch?v={youtube_id}"
|
| 33 |
-
print(f"youtube_link: {youtube_link}")
|
| 34 |
-
|
| 35 |
-
# check if origin is from junyiacademy
|
| 36 |
-
origin = request.headers.get("origin", "")
|
| 37 |
-
if "junyiacademy" in origin:
|
| 38 |
-
password_text = PASSWORD
|
| 39 |
-
admin = gr.update(visible=False)
|
| 40 |
-
reading_passage_admin = gr.update(visible=False)
|
| 41 |
-
summary_admin = gr.update(visible=False)
|
| 42 |
-
see_detail = gr.update(visible=False)
|
| 43 |
-
worksheet_accordion = gr.update(visible=False)
|
| 44 |
-
lesson_plan_accordion = gr.update(visible=False)
|
| 45 |
-
exit_ticket_accordion = gr.update(visible=False)
|
| 46 |
-
ai_chatbot_params = gr.update(visible=False)
|
| 47 |
-
|
| 48 |
-
return admin, reading_passage_admin, summary_admin, see_detail, \
|
| 49 |
-
worksheet_accordion, lesson_plan_accordion, exit_ticket_accordion, \
|
| 50 |
-
password_text, youtube_link, \
|
| 51 |
-
chatbot_open_ai_streaming, chatbot_ai, ai_chatbot_params, \
|
| 52 |
-
is_env_prod
|
| 53 |
|
| 54 |
HEAD = """
|
| 55 |
<meta charset="UTF-8">
|
|
|
|
| 3 |
|
| 4 |
# --- Init params ---
|
| 5 |
def init_params(text, request: gr.Request):
|
| 6 |
+
youtube_link = ""
|
| 7 |
+
password_text = ""
|
| 8 |
+
admin = gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
return admin, password_text, youtube_link
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
HEAD = """
|
| 13 |
<meta charset="UTF-8">
|