malikrf22 commited on
Commit
919cd69
Β·
verified Β·
1 Parent(s): 896ef4e

Upload 4 files

Browse files
Files changed (3) hide show
  1. README.md +12 -0
  2. app.py +97 -0
  3. requirements.txt +3 -0
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Genvid1
3
+ emoji: πŸ‘
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 6.9.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from huggingface_hub import hf_hub_download
4
+ import shutil
5
+ import json
6
+
7
+ # ======================================================
8
+ # 1. SETUP LOGIKA APLIKASI
9
+ # ======================================================
10
+ token_gudang = None
11
+ setup_error = None # βœ… Simpan error di variable global
12
+
13
+ try:
14
+ token_gudang = os.environ.get("KUNCI_GUDANG")
15
+
16
+ # Download script python logika
17
+ path_download_logic = hf_hub_download(
18
+ repo_id="yanti002/ide",
19
+ filename="kling_baru.py",
20
+ repo_type="dataset",
21
+ token=token_gudang
22
+ )
23
+ shutil.copy(path_download_logic, "kling_logic.py")
24
+
25
+ # Import UI dan fungsi dari script tersebut
26
+ from kling_logic import create_app_ui, set_hf_token
27
+
28
+ # Set HF Token untuk write access
29
+ set_hf_token(token_gudang)
30
+
31
+ except Exception as e:
32
+ setup_error = str(e) # βœ… Simpan error message
33
+ print(f"Error Setup Awal: {e}")
34
+
35
+ def create_app_ui():
36
+ with gr.Column(visible=False) as main_interface:
37
+ gr.Markdown(f"❌ Gagal memuat logika: {setup_error}")
38
+ return main_interface
39
+
40
+
41
+ # ======================================================
42
+ # 2. FUNGSI UPDATE PASSWORD
43
+ # ======================================================
44
+ def get_latest_passwords():
45
+ try:
46
+ path = hf_hub_download(
47
+ repo_id="yanti002/ide",
48
+ filename="freepik_passwords.json",
49
+ repo_type="dataset",
50
+ token=token_gudang,
51
+ force_download=True
52
+ )
53
+ with open(path, 'r') as f:
54
+ return json.load(f)
55
+ except Exception as e:
56
+ print(f"Gagal update password: {e}")
57
+ return []
58
+
59
+ # ======================================================
60
+ # 3. LOGIKA VERIFIKASI LOGIN
61
+ # ======================================================
62
+ def verify_login(password):
63
+ current_user_db = get_latest_passwords()
64
+
65
+ if password in current_user_db:
66
+ return {
67
+ login_row: gr.update(visible=False),
68
+ app_row: gr.update(visible=True),
69
+ status_box: "βœ… Login Sukses!"
70
+ }
71
+ else:
72
+ return {
73
+ login_row: gr.update(visible=True),
74
+ app_row: gr.update(visible=False),
75
+ status_box: "❌ Sandi salah atau belum terupdate."
76
+ }
77
+
78
+ # ======================================================
79
+ # 4. ANTARMUKA UTAMA
80
+ # ======================================================
81
+ with gr.Blocks(title="Kling Pro Studio") as demo:
82
+
83
+ with gr.Column(visible=True) as login_row:
84
+ gr.Markdown("## πŸ” Login Real-time")
85
+ with gr.Group():
86
+ password_input = gr.Textbox(label="Kode Akses", type="password")
87
+ login_btn = gr.Button("MASUK", variant="primary")
88
+ status_box = gr.Textbox(label="Status", interactive=False)
89
+
90
+ app_row = create_app_ui()
91
+
92
+ # Event Listeners
93
+ login_btn.click(fn=verify_login, inputs=password_input, outputs=[login_row, app_row, status_box])
94
+ password_input.submit(fn=verify_login, inputs=password_input, outputs=[login_row, app_row, status_box])
95
+
96
+ if __name__ == "__main__":
97
+ demo.queue(max_size=500, default_concurrency_limit=100).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ requests
3
+ huggingface_hub