Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3123,6 +3123,53 @@ def logout_user_with_ui_and_session():
|
|
| 3123 |
init_user_db()
|
| 3124 |
|
| 3125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3126 |
with gr.Blocks(css=custom_css) as demo:
|
| 3127 |
current_user = gr.State({})
|
| 3128 |
session_user_json = gr.Textbox(visible=False, elem_id="rebom_session_user_json")
|
|
@@ -3279,7 +3326,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3279 |
""")
|
| 3280 |
gr.Markdown("### Screening")
|
| 3281 |
|
| 3282 |
-
with gr.Tab("๐ ๋ก๊ทธ์ธ"):
|
| 3283 |
gr.Markdown("## ๐ ๋ก๊ทธ์ธ")
|
| 3284 |
gr.Markdown("์น์ธ๋ ๊ณ์ ๋ง ์คํฌ๋ฆฌ๋ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3285 |
|
|
@@ -3290,7 +3337,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3290 |
logout_btn = gr.Button("๋ก๊ทธ์์", variant="secondary")
|
| 3291 |
login_status = gr.Textbox(label="๋ก๊ทธ์ธ ์ํ", interactive=False, lines=3)
|
| 3292 |
|
| 3293 |
-
with gr.Tab("๐ ํ์๊ฐ์
์ ์ฒญ"):
|
| 3294 |
gr.Markdown("## ๐ ํ์๊ฐ์
์ ์ฒญ")
|
| 3295 |
gr.Markdown("ํ, ์ด๋ฆ, ๋ฉ์ผ ์ฃผ์, ๋น๋ฐ๋ฒํธ๋ฅผ ์
๋ ฅํ๋ฉด ๊ด๋ฆฌ์ ์น์ธ ํ ์ฌ์ดํธ ์ด์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.")
|
| 3296 |
|
|
@@ -3314,7 +3361,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3314 |
outputs=signup_status,
|
| 3315 |
)
|
| 3316 |
|
| 3317 |
-
with gr.Tab("๐ ์คํฌ๋ฆฌ๋"
|
| 3318 |
gr.Markdown("## ๐ ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋")
|
| 3319 |
gr.Markdown("๋ก๊ทธ์ธ ๋ฐ ๊ด๋ฆฌ์ ์น์ธ ์๋ฃ ํ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3320 |
|
|
@@ -3339,7 +3386,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3339 |
outputs=[df_out,file_out,msg_out],
|
| 3340 |
)
|
| 3341 |
|
| 3342 |
-
with gr.Tab("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์"
|
| 3343 |
gr.Markdown("## ๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์")
|
| 3344 |
gr.Markdown("๋ก๊ทธ์ธ ๋ฐ ๊ด๋ฆฌ์ ์น์ธ ์๋ฃ ํ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3345 |
|
|
@@ -3455,6 +3502,9 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3455 |
|
| 3456 |
|
| 3457 |
try:
|
| 3458 |
-
demo.launch(
|
|
|
|
|
|
|
| 3459 |
except TypeError:
|
| 3460 |
demo.launch(server_name="0.0.0.0",server_port=7860,share=True,allowed_paths=ALLOWED_PATHS,blocked_paths=BLOCKED_PATHS)
|
|
|
|
|
|
| 3123 |
init_user_db()
|
| 3124 |
|
| 3125 |
|
| 3126 |
+
|
| 3127 |
+
# ============================================================
|
| 3128 |
+
# Gradio ๊ธฐ๋ณธ ๋ก๊ทธ์ธ: ๋ค์ค ์์ด๋/๋น๋ฐ๋ฒํธ ๋ฑ๋ก
|
| 3129 |
+
# ============================================================
|
| 3130 |
+
# ์ฌ์ดํธ ์ ์ ์ Gradio ๊ธฐ๋ณธ ๋ก๊ทธ์ธ์ฐฝ์ด ๋จ๊ณ ,
|
| 3131 |
+
# ์๋ USER_DB์ ๋ฑ๋ก๋ ์์ด๋/๋น๋ฐ๋ฒํธ๋ก๋ง ์ ์ํ ์ ์์ต๋๋ค.
|
| 3132 |
+
#
|
| 3133 |
+
# ์ฌ์ฉ์๋ฅผ ์ถ๊ฐํ๋ ค๋ฉด ์๋์ฒ๋ผ ํ ์ค์ฉ ์ถ๊ฐํ์ธ์.
|
| 3134 |
+
# "๋ฉ์ผ์ฃผ์": "๋น๋ฐ๋ฒํธ",
|
| 3135 |
+
# ============================================================
|
| 3136 |
+
|
| 3137 |
+
USER_DB = {
|
| 3138 |
+
"jin2li@rebom.kr": "qwer0515!",
|
| 3139 |
+
|
| 3140 |
+
# ์ฌ์ฉ์ ์ถ๊ฐ ์์:
|
| 3141 |
+
# "yubin.p@rebom.kr": "์ํ๋๋น๋ฐ๋ฒํธ",
|
| 3142 |
+
# "user2@rebom.kr": "์ํ๋๋น๋ฐ๋ฒํธ2",
|
| 3143 |
+
}
|
| 3144 |
+
|
| 3145 |
+
|
| 3146 |
+
def auth_fn(username, password):
|
| 3147 |
+
username = safe_str(username).lower()
|
| 3148 |
+
password = safe_str(password)
|
| 3149 |
+
|
| 3150 |
+
return USER_DB.get(username) == password
|
| 3151 |
+
|
| 3152 |
+
|
| 3153 |
+
|
| 3154 |
+
|
| 3155 |
+
# ============================================================
|
| 3156 |
+
# Gradio ๊ธฐ๋ณธ auth ์ฌ์ฉ ์ ๋ด๋ถ ๋ก๊ทธ์ธ ์ฒดํฌ ์ฐํ
|
| 3157 |
+
# ============================================================
|
| 3158 |
+
|
| 3159 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=30, live_headless=True):
|
| 3160 |
+
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3161 |
+
|
| 3162 |
+
|
| 3163 |
+
def process_single_ingredient_with_auth(user, countries, single_query, single_amount, single_function, single_use_mfds_live=False):
|
| 3164 |
+
return process_single_ingredient(
|
| 3165 |
+
countries,
|
| 3166 |
+
single_query,
|
| 3167 |
+
single_amount,
|
| 3168 |
+
single_function,
|
| 3169 |
+
single_use_mfds_live,
|
| 3170 |
+
)
|
| 3171 |
+
|
| 3172 |
+
|
| 3173 |
with gr.Blocks(css=custom_css) as demo:
|
| 3174 |
current_user = gr.State({})
|
| 3175 |
session_user_json = gr.Textbox(visible=False, elem_id="rebom_session_user_json")
|
|
|
|
| 3326 |
""")
|
| 3327 |
gr.Markdown("### Screening")
|
| 3328 |
|
| 3329 |
+
with gr.Tab("๐ ๋ก๊ทธ์ธ", visible=False):
|
| 3330 |
gr.Markdown("## ๐ ๋ก๊ทธ์ธ")
|
| 3331 |
gr.Markdown("์น์ธ๋ ๊ณ์ ๋ง ์คํฌ๋ฆฌ๋ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3332 |
|
|
|
|
| 3337 |
logout_btn = gr.Button("๋ก๊ทธ์์", variant="secondary")
|
| 3338 |
login_status = gr.Textbox(label="๋ก๊ทธ์ธ ์ํ", interactive=False, lines=3)
|
| 3339 |
|
| 3340 |
+
with gr.Tab("๐ ํ์๊ฐ์
์ ์ฒญ", visible=False):
|
| 3341 |
gr.Markdown("## ๐ ํ์๊ฐ์
์ ์ฒญ")
|
| 3342 |
gr.Markdown("ํ, ์ด๋ฆ, ๋ฉ์ผ ์ฃผ์, ๋น๋ฐ๋ฒํธ๋ฅผ ์
๋ ฅํ๋ฉด ๊ด๋ฆฌ์ ์น์ธ ํ ์ฌ์ดํธ ์ด์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.")
|
| 3343 |
|
|
|
|
| 3361 |
outputs=signup_status,
|
| 3362 |
)
|
| 3363 |
|
| 3364 |
+
with gr.Tab("๐ ์คํฌ๋ฆฌ๋") as screening_tab:
|
| 3365 |
gr.Markdown("## ๐ ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋")
|
| 3366 |
gr.Markdown("๋ก๊ทธ์ธ ๋ฐ ๊ด๋ฆฌ์ ์น์ธ ์๋ฃ ํ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3367 |
|
|
|
|
| 3386 |
outputs=[df_out,file_out,msg_out],
|
| 3387 |
)
|
| 3388 |
|
| 3389 |
+
with gr.Tab("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์") as single_tab:
|
| 3390 |
gr.Markdown("## ๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์")
|
| 3391 |
gr.Markdown("๋ก๊ทธ์ธ ๋ฐ ๊ด๋ฆฌ์ ์น์ธ ์๋ฃ ํ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
| 3392 |
|
|
|
|
| 3502 |
|
| 3503 |
|
| 3504 |
try:
|
| 3505 |
+
demo.launch(
|
| 3506 |
+
auth=auth_fn,
|
| 3507 |
+
server_name="0.0.0.0",server_port=7860,share=True,ssr_mode=False,allowed_paths=ALLOWED_PATHS,blocked_paths=BLOCKED_PATHS,show_api=False,footer_links=[],app_kwargs={"docs_url":None,"redoc_url":None,"openapi_url":None})
|
| 3508 |
except TypeError:
|
| 3509 |
demo.launch(server_name="0.0.0.0",server_port=7860,share=True,allowed_paths=ALLOWED_PATHS,blocked_paths=BLOCKED_PATHS)
|
| 3510 |
+
|