jin2li commited on
Commit
2525f7f
ยท
verified ยท
1 Parent(s): 6a2eddc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -17
app.py CHANGED
@@ -3069,11 +3069,10 @@ init_user_db()
3069
 
3070
  USER_DB = {
3071
  "jin2li@rebom.kr": "qwer0515!",
3072
-
3073
  # ์‚ฌ์šฉ์ž ์ถ”๊ฐ€ ์˜ˆ์‹œ:
3074
  # "yubin.p@rebom.kr": "์›ํ•˜๋Š”๋น„๋ฐ€๋ฒˆํ˜ธ",
3075
- # "jkh@rebom.kr": "rebom123!",
3076
- }
3077
 
3078
 
3079
  def auth_fn(username, password):
@@ -3179,10 +3178,46 @@ def process_single_ingredient_with_auth(user, countries, single_query, single_am
3179
  )
3180
 
3181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3182
  with gr.Blocks(css=custom_css) as demo:
3183
  current_user = gr.State({})
3184
  session_user_json = gr.Textbox(visible=False, elem_id="rebom_session_user_json")
3185
- restore_session_btn = gr.Button("restore session", visible=False, elem_id="rebom_restore_session_btn_disabled")
3186
 
3187
  gr.Markdown("# ๐ŸŒ reBom")
3188
  gr.HTML("""
@@ -3342,18 +3377,7 @@ with gr.Blocks(css=custom_css) as demo:
3342
  variant="secondary",
3343
  )
3344
 
3345
- with gr.Tab("๐Ÿ” ๋กœ๊ทธ์ธ", visible=False):
3346
- gr.Markdown("## ๐Ÿ” ๋กœ๊ทธ์ธ")
3347
- gr.Markdown("์Šน์ธ๋œ ๊ณ„์ •๋งŒ ์Šคํฌ๋ฆฌ๋‹ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.")
3348
-
3349
- login_email = gr.Textbox(label="๋ฉ”์ผ ์ฃผ์†Œ", placeholder="example@rebom.kr")
3350
- remember_email = gr.Checkbox(label="์•„์ด๋”” ์ €์žฅ", value=False)
3351
- login_password = gr.Textbox(label="๋น„๋ฐ€๋ฒˆํ˜ธ", type="password")
3352
- login_btn = gr.Button("๋กœ๊ทธ์ธ", variant="primary")
3353
- logout_btn = gr.Button("๋กœ๊ทธ์•„์›ƒ", variant="secondary")
3354
- login_status = gr.Textbox(label="๋กœ๊ทธ์ธ ์ƒํƒœ", interactive=False, lines=3)
3355
-
3356
- with gr.Tab("๐Ÿ“ ๊ณ„์ • ๋“ฑ๋ก์€ ๊ด€๋ฆฌ์ž์—๊ฒŒ ์š”์ฒญ", visible=False):
3357
  gr.Markdown("## ๐Ÿ“ ๊ณ„์ • ๋“ฑ๋ก์€ ๊ด€๋ฆฌ์ž์—๊ฒŒ ์š”์ฒญ")
3358
  gr.Markdown("ํŒ€, ์ด๋ฆ„, ๋ฉ”์ผ ์ฃผ์†Œ, ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ด€๋ฆฌ์ž ์Šน์ธ ํ›„ ์‚ฌ์ดํŠธ ์ด์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.")
3359
 
@@ -3425,7 +3449,7 @@ with gr.Blocks(css=custom_css) as demo:
3425
  outputs=[single_df_out,single_msg_out],
3426
  )
3427
 
3428
- with gr.Tab("๐Ÿ‘‘ ํšŒ์› ์Šน์ธ ๊ด€๋ฆฌ", visible=False) as admin_tab:
3429
  gr.Markdown("## ๐Ÿ‘‘ ํšŒ์› ์Šน์ธ ๊ด€๋ฆฌ")
3430
  gr.Markdown("๊ด€๋ฆฌ์ž ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•œ ๊ฒฝ์šฐ์—๋งŒ ์Šน์ธ/๊ฑฐ์ ˆํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.")
3431
 
 
3069
 
3070
  USER_DB = {
3071
  "jin2li@rebom.kr": "qwer0515!",
3072
+ "jkh@rebom.kr": "rebom123!"
3073
  # ์‚ฌ์šฉ์ž ์ถ”๊ฐ€ ์˜ˆ์‹œ:
3074
  # "yubin.p@rebom.kr": "์›ํ•˜๋Š”๋น„๋ฐ€๋ฒˆํ˜ธ",
3075
+ }
 
3076
 
3077
 
3078
  def auth_fn(username, password):
 
3178
  )
3179
 
3180
 
3181
+
3182
+ # ============================================================
3183
+ # ๋กœ๊ทธ์ธ ์ธ์ฆ
3184
+ # - Gradio ๊ธฐ๋ณธ ๋กœ๊ทธ์ธ์ฐฝ ์‚ฌ์šฉ
3185
+ # - ์•„๋ž˜ USER_DB์— ๋ฉ”์ผ/๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ง์ ‘ ๋“ฑ๋ก
3186
+ # ============================================================
3187
+
3188
+ USER_DB = {
3189
+ "jin2li@rebom.kr": "qwer0515!",
3190
+
3191
+ # ์‚ฌ์šฉ์ž ๋“ฑ๋ก ์˜ˆ์‹œ:
3192
+ # "yubin.p@rebom.kr": "123456!",
3193
+ # "jkh@rebom.kr": "rebom123!",
3194
+ }
3195
+
3196
+
3197
+ def auth_fn(username, password):
3198
+ username = str(username).strip().lower()
3199
+ password = str(password).strip()
3200
+ return USER_DB.get(username) == password
3201
+
3202
+
3203
+ def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=30, live_headless=True):
3204
+ return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
3205
+
3206
+
3207
+ def process_single_ingredient_with_auth(user, countries, single_query, single_amount, single_function, single_use_mfds_live=False):
3208
+ return process_single_ingredient(
3209
+ countries,
3210
+ single_query,
3211
+ single_amount,
3212
+ single_function,
3213
+ single_use_mfds_live,
3214
+ )
3215
+
3216
+
3217
  with gr.Blocks(css=custom_css) as demo:
3218
  current_user = gr.State({})
3219
  session_user_json = gr.Textbox(visible=False, elem_id="rebom_session_user_json")
3220
+ restore_session_btn = gr.Button("restore session", elem_id="rebom_restore_session_btn_disabled")
3221
 
3222
  gr.Markdown("# ๐ŸŒ reBom")
3223
  gr.HTML("""
 
3377
  variant="secondary",
3378
  )
3379
 
3380
+ with gr.Tab("๐Ÿ“ ๊ณ„์ • ๋“ฑ๋ก์€ ๊ด€๋ฆฌ์ž์—๊ฒŒ ์š”์ฒญ"):
 
 
 
 
 
 
 
 
 
 
 
3381
  gr.Markdown("## ๐Ÿ“ ๊ณ„์ • ๋“ฑ๋ก์€ ๊ด€๋ฆฌ์ž์—๊ฒŒ ์š”์ฒญ")
3382
  gr.Markdown("ํŒ€, ์ด๋ฆ„, ๋ฉ”์ผ ์ฃผ์†Œ, ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ด€๋ฆฌ์ž ์Šน์ธ ํ›„ ์‚ฌ์ดํŠธ ์ด์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.")
3383
 
 
3449
  outputs=[single_df_out,single_msg_out],
3450
  )
3451
 
3452
+ with gr.Tab("๐Ÿ‘‘ ํšŒ์› ์Šน์ธ ๊ด€๋ฆฌ") as admin_tab:
3453
  gr.Markdown("## ๐Ÿ‘‘ ํšŒ์› ์Šน์ธ ๊ด€๋ฆฌ")
3454
  gr.Markdown("๊ด€๋ฆฌ์ž ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•œ ๊ฒฝ์šฐ์—๋งŒ ์Šน์ธ/๊ฑฐ์ ˆํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.")
3455