Mikka2026 commited on
Commit
e8fbc50
·
verified ·
1 Parent(s): cd78ad9

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +489 -19
index.html CHANGED
@@ -1,19 +1,489 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Backup Script Generator</title>
7
+ <!-- Font Awesome for Icons -->
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ :root {
11
+ --primary: #4f46e5;
12
+ --primary-hover: #4338ca;
13
+ --secondary: #ec4899;
14
+ --bg-dark: #0f172a;
15
+ --bg-panel: #1e293b;
16
+ --text-main: #f8fafc;
17
+ --text-muted: #94a3b8;
18
+ --border: #334155;
19
+ --code-bg: #282c34;
20
+ --success: #10b981;
21
+ }
22
+
23
+ * {
24
+ box-sizing: box-box;
25
+ margin: 0;
26
+ padding: 0;
27
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
28
+ }
29
+
30
+ body {
31
+ background-color: var(--bg-dark);
32
+ color: var(--text-main);
33
+ min-height: 100vh;
34
+ display: flex;
35
+ flex-direction: column;
36
+ }
37
+
38
+ /* Header & Nav */
39
+ header {
40
+ background: rgba(15, 23, 42, 0.8);
41
+ border-bottom: 1px solid var(--border);
42
+ padding: 1rem 2rem;
43
+ display: flex;
44
+ justify-content: space-between;
45
+ align-items: center;
46
+ backdrop-filter: blur(10px);
47
+ position: sticky;
48
+ top: 0;
49
+ z-index: 100;
50
+ }
51
+
52
+ .brand {
53
+ font-weight: 700;
54
+ font-size: 1.25rem;
55
+ display: flex;
56
+ align-items: center;
57
+ gap: 10px;
58
+ }
59
+
60
+ .brand i {
61
+ color: var(--primary);
62
+ }
63
+
64
+ .anycoder-link {
65
+ background: var(--bg-panel);
66
+ padding: 8px 16px;
67
+ border-radius: 8px;
68
+ text-decoration: none;
69
+ color: var(--text-main);
70
+ font-size: 0.85rem;
71
+ font-weight: 600;
72
+ border: 1px solid var(--border);
73
+ transition: all 0.3s ease;
74
+ display: flex;
75
+ align-items: center;
76
+ gap: 8px;
77
+ }
78
+
79
+ .anycoder-link:hover {
80
+ background: var(--primary);
81
+ border-color: var(--primary);
82
+ transform: translateY(-2px);
83
+ }
84
+
85
+ /* Main Layout */
86
+ main {
87
+ display: grid;
88
+ grid-template-columns: 1fr;
89
+ gap: 2rem;
90
+ padding: 2rem;
91
+ max-width: 1400px;
92
+ width: 100%;
93
+ margin: 0 auto;
94
+ flex-grow: 1;
95
+ }
96
+
97
+ @media (min-width: 1024px) {
98
+ main {
99
+ grid-template-columns: 400px 1fr;
100
+ }
101
+ }
102
+
103
+ /* Configuration Panel */
104
+ .config-panel {
105
+ background: var(--bg-panel);
106
+ padding: 2rem;
107
+ border-radius: 16px;
108
+ border: 1px solid var(--border);
109
+ height: fit-content;
110
+ }
111
+
112
+ .panel-title {
113
+ margin-bottom: 1.5rem;
114
+ font-size: 1.5rem;
115
+ color: var(--text-main);
116
+ }
117
+
118
+ .panel-title span {
119
+ color: var(--primary);
120
+ }
121
+
122
+ .form-group {
123
+ margin-bottom: 1.25rem;
124
+ }
125
+
126
+ .form-label {
127
+ display: block;
128
+ margin-bottom: 0.5rem;
129
+ color: var(--text-muted);
130
+ font-size: 0.9rem;
131
+ font-weight: 500;
132
+ }
133
+
134
+ .form-input {
135
+ width: 100%;
136
+ background: var(--bg-dark);
137
+ border: 1px solid var(--border);
138
+ padding: 0.75rem 1rem;
139
+ color: var(--text-main);
140
+ border-radius: 8px;
141
+ font-size: 0.95rem;
142
+ transition: border-color 0.2s;
143
+ }
144
+
145
+ .form-input:focus {
146
+ outline: none;
147
+ border-color: var(--primary);
148
+ box-shadow: 0 0 0 3px rgba(79, 46, 229, 0.1);
149
+ }
150
+
151
+ .checkbox-group {
152
+ display: flex;
153
+ align-items: center;
154
+ gap: 10px;
155
+ margin-top: 10px;
156
+ }
157
+
158
+ .checkbox-group input {
159
+ accent-color: var(--primary);
160
+ width: 16px;
161
+ height: 16px;
162
+ }
163
+
164
+ /* Code Preview Panel */
165
+ .code-panel {
166
+ display: flex;
167
+ flex-direction: column;
168
+ background: var(--bg-panel);
169
+ border-radius: 16px;
170
+ border: 1px solid var(--border);
171
+ overflow: hidden;
172
+ position: relative;
173
+ }
174
+
175
+ .code-header {
176
+ padding: 1rem 1.5rem;
177
+ background: rgba(15, 23, 42, 0.5);
178
+ border-bottom: 1px solid var(--border);
179
+ display: flex;
180
+ justify-content: space-between;
181
+ align-items: center;
182
+ }
183
+
184
+ .code-actions {
185
+ display: flex;
186
+ gap: 10px;
187
+ }
188
+
189
+ .btn {
190
+ padding: 0.6rem 1.2rem;
191
+ border-radius: 6px;
192
+ font-weight: 600;
193
+ cursor: pointer;
194
+ border: none;
195
+ transition: all 0.2s;
196
+ font-size: 0.9rem;
197
+ display: flex;
198
+ align-items: center;
199
+ gap: 8px;
200
+ }
201
+
202
+ .btn-copy {
203
+ background: var(--primary);
204
+ color: white;
205
+ }
206
+
207
+ .btn-copy:hover {
208
+ background: var(--primary-hover);
209
+ }
210
+
211
+ .btn-download {
212
+ background: transparent;
213
+ border: 1px solid var(--border);
214
+ color: var(--text-muted);
215
+ }
216
+
217
+ .btn-download:hover {
218
+ border-color: var(--text-main);
219
+ color: var(--text-main);
220
+ }
221
+
222
+ .code-content {
223
+ flex-grow: 1;
224
+ padding: 1.5rem;
225
+ overflow: auto;
226
+ background: #1a1b26;
227
+ font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
228
+ font-size: 0.85rem;
229
+ line-height: 1.6;
230
+ color: #a9b7c6;
231
+ }
232
+
233
+ /* Syntax Highlighting Simulation */
234
+ .kw { color: #c678dd; } /* Keywords */
235
+ .str { color: #98c379; } /* Strings */
236
+ .num { color: #d19a66; } /* Numbers */
237
+ .func { color: #61afef; } /* Functions */
238
+ .comment { color: #5c6370; font-style: italic; } /* Comments */
239
+ .class { color: #e5c07b; } /* Classes */
240
+
241
+ /* Toast Notification */
242
+ .toast {
243
+ position: fixed;
244
+ bottom: 20px;
245
+ right: 20px;
246
+ background: var(--success);
247
+ color: white;
248
+ padding: 1rem 2rem;
249
+ border-radius: 8px;
250
+ transform: translateY(100px);
251
+ opacity: 0;
252
+ transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
253
+ font-weight: 600;
254
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
255
+ z-index: 1000;
256
+ }
257
+
258
+ .toast.show {
259
+ transform: translateY(0);
260
+ opacity: 1;
261
+ }
262
+
263
+ /* Responsive Adjustments */
264
+ @media (max-width: 768px) {
265
+ header {
266
+ padding: 1rem;
267
+ }
268
+ main {
269
+ padding: 1rem;
270
+ }
271
+ .code-header {
272
+ flex-direction: column;
273
+ gap: 10px;
274
+ align-items: flex-start;
275
+ }
276
+ }
277
+ </style>
278
+ </head>
279
+ <body>
280
+
281
+ <header>
282
+ <div class="brand">
283
+ <i class="fa-solid fa-server"></i>
284
+ BackupGen
285
+ </div>
286
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
287
+ <i class="fa-solid fa-robot"></i> Built with anycoder
288
+ </a>
289
+ </header>
290
+
291
+ <main>
292
+ <!-- Configuration Side -->
293
+ <section class="config-panel">
294
+ <h2 class="panel-title">Configuration <span>Settings</span></h2>
295
+
296
+ <div class="form-group">
297
+ <label class="form-label">Source Network Path</label>
298
+ <input type="text" id="sourcePath" class="form-input" placeholder="\\\\Server\Share\Folder" value="//192.168.1.50/Backups">
299
+ </div>
300
+
301
+ <div class="form-group">
302
+ <label class="form-label">Local Destination Path</label>
303
+ <input type="text" id="destPath" class="form-input" placeholder="D:\LocalBackup" value="C:/Backup/LocalDrive">
304
+ </div>
305
+
306
+ <div class="form-group">
307
+ <label class="form-label">Email Notification Address</label>
308
+ <input type="email" id="emailAddr" class="form-input" placeholder="admin@company.com" value="admin@example.com">
309
+ </div>
310
+
311
+ <div class="form-group">
312
+ <label class="form-label">SMTP Server (e.g., smtp.gmail.com)</label>
313
+ <input type="text" id="smtpServer" class="form-input" placeholder="smtp.gmail.com" value="smtp.gmail.com">
314
+ </div>
315
+
316
+ <div class="form-group">
317
+ <label class="form-label">SMTP Port</label>
318
+ <input type="number" id="smtpPort" class="form-input" value="587">
319
+ </div>
320
+
321
+ <div class="checkbox-group">
322
+ <input type="checkbox" id="dryRun">
323
+ <label class="form-label" for="dryRun">Dry Run Mode (Don't actually copy, just log)</label>
324
+ </div>
325
+ </section>
326
+
327
+ <!-- Code Preview Side -->
328
+ <section class="code-panel">
329
+ <div class="code-header">
330
+ <div class="badge" style="color: var(--secondary); font-weight: bold; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;">
331
+ <i class="fa-brands fa-python"></i> Python Script
332
+ </div>
333
+ <div class="code-actions">
334
+ <button class="btn btn-download" onclick="downloadScript()">
335
+ <i class="fa-solid fa-download"></i> Download
336
+ </button>
337
+ <button class="btn btn-copy" onclick="copyCode()">
338
+ <i class="fa-solid fa-copy"></i> Copy Code
339
+ </button>
340
+ </div>
341
+ </div>
342
+ <div class="code-content" id="codeOutput">
343
+ <!-- Code will be injected here -->
344
+ </div>
345
+ </section>
346
+ </main>
347
+
348
+ <div class="toast" id="toast">Code copied to clipboard!</div>
349
+
350
+ <script>
351
+ // DOM Elements
352
+ const inputs = {
353
+ source: document.getElementById('sourcePath'),
354
+ dest: document.getElementById('destPath'),
355
+ email: document.getElementById('emailAddr'),
356
+ smtp: document.getElementById('smtpServer'),
357
+ port: document.getElementById('smtpPort'),
358
+ dryRun: document.getElementById('dryRun')
359
+ };
360
+ const codeOutput = document.getElementById('codeOutput');
361
+ const toast = document.getElementById('toast');
362
+
363
+ // Python Template Logic
364
+ function generateCode() {
365
+ const source = inputs.source.value;
366
+ const dest = inputs.dest.value;
367
+ const email = inputs.email.value;
368
+ const smtp = inputs.smtp.value;
369
+ const port = inputs.port.value;
370
+ const dryRun = inputs.dryRun.checked;
371
+
372
+ // Constructing the Python code string with syntax highlighting classes
373
+ return `
374
+ <span class="kw">import</span> os
375
+ <span class="kw">import</span> shutil
376
+ <span class="kw">import</span> smtplib
377
+ <span class="kw">import</span> datetime
378
+ <span class="kw">from</span> email.mime.text <span class="kw">import</span> MIMEText
379
+ <span class="kw">from</span> email.mime.multipart <span class="kw">import</span> MIMEMultipart
380
+
381
+ <span class="comment"># Configuration Variables</span>
382
+ SOURCE_PATH = <span class="str">"${source}"</span>
383
+ DEST_PATH = <span class="str">"${dest}"</span>
384
+ EMAIL_RECIPIENT = <span class="str">"${email}"</span>
385
+ SMTP_SERVER = <span class="str">"${smtp}"</span>
386
+ SMTP_PORT = <span class="num">${port}</span>
387
+ DRY_RUN = <span class="kw">${dryRun}</span>
388
+
389
+ <span class="kw">def</span> <span class="func">send_notification</span>(success, details):
390
+ <span class="kw">try</span>:
391
+ msg = MIMEMultipart(<span class="str">'alternative'</span>)
392
+ subject = <span class="str">f"Backup Status: {'Success' if success else 'Failed'}"</span>
393
+ body = <span class="str">f"Backup completed at {datetime.datetime.now()}\\nDetails: {details}"</span>
394
+
395
+ msg[<span class="str">'Subject'</span>] = subject
396
+ msg[<span class="str">'From'</span>] = EMAIL_RECIPIENT
397
+ msg[<span class="str">'To'</span>] = EMAIL_RECIPIENT
398
+
399
+ msg.attach(MIMEText(body, <span class="str">'plain'</span>)
400
+
401
+ <span class="kw">if</span> not DRY_RUN:
402
+ <span class="comment"># NOTE: Replace with actual credentials in production</span>
403
+ <span class="kw">with</span> smtplib.SMTP(SMTP_SERVER, SMTP_PORT) <span class="kw">as</span> server:
404
+ server.login(<span class="str">"YOUR_EMAIL"</span>, <span class="str">"YOUR_PASSWORD"</span>)
405
+ server.send_message(msg.as_string())
406
+ <span class="kw">except</span> Exception <span class="kw">as</span> e:
407
+ print(<span class="str">f"Email error: {e}"</span>)
408
+
409
+ <span class="kw">def</span> <span class="func">incremental_backup</span>(src, dst):
410
+ files_copied = 0
411
+ errors = []
412
+
413
+ <span class="kw">if</span> not os.path.exists(dst):
414
+ os.makedirs(dst)
415
+
416
+ <span class="kw">for</span> item <span class="kw">in</span> os.listdir(src):
417
+ src_item = os.path.join(src, item)
418
+ dst_item = os.path.join(dst, item)
419
+
420
+ <span class="kw">if</span> os.path.isdir(src_item):
421
+ <span class="kw">if</span> not os.path.exists(dst_item):
422
+ shutil.copytree(src_item, dst_item)
423
+ files_copied += 1
424
+ <span class="kw">else</span>:
425
+ <span class="comment"># Recursive call for subdirectories</span>
426
+ files_copied += incremental_backup(src_item, dst_item)
427
+ <span class="kw">else</span>:
428
+ <span class="comment"># Check if file needs update (Incremental logic)</span>
429
+ <span class="kw">if</span> not os.path.exists(dst_item) <span class="kw">or</span>
430
+ os.path.getmtime(src_item) > os.path.getmtime(dst_item):
431
+ <span class="kw">if</span> not DRY_RUN:
432
+ shutil.copy2(src_item, dst_item)
433
+ files_copied += 1
434
+
435
+ <span class="kw">return</span> files_copied
436
+
437
+ <span class="kw">if</span> __name__ == <span class="str">"__main__"</span>:
438
+ print(<span class="str">"Starting backup process..."</span>)
439
+ <span class="kw">try</span>:
440
+ count = incremental_backup(SOURCE_PATH, DEST_PATH)
441
+ send_notification(<span class="kw">True</span>, <span class="str">f"Copied {count} items."</span>)
442
+ <span class="kw">except</span> Exception <span class="kw">as</span> e:
443
+ send_notification(<span class="kw">False</span>, str(e))
444
+ `;
445
+ }
446
+
447
+ // Initial Render
448
+ codeOutput.innerHTML = generateCode();
449
+
450
+ // Update on Input Change
451
+ Object.values(inputs).forEach(input => {
452
+ input.addEventListener('input', () => {
453
+ codeOutput.innerHTML = generateCode();
454
+ });
455
+ });
456
+
457
+ // Copy Functionality
458
+ function copyCode() {
459
+ // Get raw text without HTML tags for copying
460
+ const rawCode = codeOutput.innerText;
461
+ navigator.clipboard.writeText(rawCode).then(() => {
462
+ showToast();
463
+ });
464
+ }
465
+
466
+ // Download Functionality
467
+ function downloadScript() {
468
+ const rawCode = codeOutput.innerText;
469
+ const blob = new Blob([rawCode], { type: 'text/x-python' });
470
+ const url = window.URL.createObjectURL(blob);
471
+ const a = document.createElement('a');
472
+ a.href = url;
473
+ a.download = 'backup_script.py';
474
+ document.body.appendChild(a);
475
+ a.click();
476
+ document.body.removeChild(a);
477
+ window.URL.revokeObjectURL(url);
478
+ }
479
+
480
+ // Toast Animation
481
+ function showToast() {
482
+ toast.classList.add('show');
483
+ setTimeout(() => {
484
+ toast.classList.remove('show');
485
+ }, 3000);
486
+ }
487
+ </script>
488
+ </body>
489
+ </html>