| import os |
| import gradio as gr |
| from huggingface_hub import hf_hub_download |
| import shutil |
| import json |
|
|
| |
| |
| |
| token_gudang = None |
| setup_error = None |
|
|
| try: |
| token_gudang = os.environ.get("KUNCI_GUDANG") |
| |
| |
| path_download_logic = hf_hub_download( |
| repo_id="malikrf22/abcx", |
| filename="kling_baru.py", |
| repo_type="dataset", |
| token=token_gudang |
| ) |
| shutil.copy(path_download_logic, "kling_logic.py") |
|
|
| |
| from kling_logic import create_app_ui, set_hf_token |
| |
| |
| set_hf_token(token_gudang) |
|
|
| except Exception as e: |
| setup_error = str(e) |
| print(f"Error Setup Awal: {e}") |
| |
| def create_app_ui(): |
| with gr.Column(visible=False) as main_interface: |
| gr.Markdown(f"β Gagal memuat logika: {setup_error}") |
| return main_interface |
|
|
|
|
| |
| |
| |
| def get_latest_passwords(): |
| try: |
| path = hf_hub_download( |
| repo_id="malikrf22/abcx", |
| filename="freepik_passwords.json", |
| repo_type="dataset", |
| token=token_gudang, |
| force_download=True |
| ) |
| with open(path, 'r') as f: |
| return json.load(f) |
| except Exception as e: |
| print(f"Gagal update password: {e}") |
| return [] |
|
|
| |
| |
| |
| def verify_login(password): |
| current_user_db = get_latest_passwords() |
| |
| if password in current_user_db: |
| return { |
| login_row: gr.update(visible=False), |
| app_row: gr.update(visible=True), |
| status_box: "β
Login Sukses!" |
| } |
| else: |
| return { |
| login_row: gr.update(visible=True), |
| app_row: gr.update(visible=False), |
| status_box: "β Sandi salah atau belum terupdate." |
| } |
|
|
| |
| |
| |
| with gr.Blocks(title="Kling Pro Studio") as demo: |
| |
| with gr.Column(visible=True) as login_row: |
| gr.Markdown("## π Login Real-time") |
| with gr.Group(): |
| password_input = gr.Textbox(label="Kode Akses", type="password") |
| login_btn = gr.Button("MASUK", variant="primary") |
| status_box = gr.Textbox(label="Status", interactive=False) |
|
|
| app_row = create_app_ui() |
|
|
| |
| login_btn.click(fn=verify_login, inputs=password_input, outputs=[login_row, app_row, status_box]) |
| password_input.submit(fn=verify_login, inputs=password_input, outputs=[login_row, app_row, status_box]) |
|
|
| if __name__ == "__main__": |
| demo.queue(max_size=500, default_concurrency_limit=100).launch() |