Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -398,160 +398,160 @@ def create_interface():
|
|
| 398 |
return None, f"Error: {str(e)}", ""
|
| 399 |
|
| 400 |
def create_interface():
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
|
| 556 |
def main():
|
| 557 |
# Configure system settings
|
|
|
|
| 398 |
return None, f"Error: {str(e)}", ""
|
| 399 |
|
| 400 |
def create_interface():
|
| 401 |
+
"""Create a comprehensive Gradio interface with advanced features and styling"""
|
| 402 |
+
|
| 403 |
+
css = """
|
| 404 |
+
body {
|
| 405 |
+
background-color: #0c0c0c;
|
| 406 |
+
color: #ffffff;
|
| 407 |
+
font-family: 'Roboto', sans-serif;
|
| 408 |
+
}
|
| 409 |
+
.container {
|
| 410 |
+
max-width: 1200px;
|
| 411 |
+
margin: auto;
|
| 412 |
+
border-radius: 10px;
|
| 413 |
+
padding: 20px;
|
| 414 |
+
box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
|
| 415 |
+
background: linear-gradient(180deg, rgba(0, 255, 0, 0.1), rgba(255, 165, 0, 0.1));
|
| 416 |
+
}
|
| 417 |
+
h1 {
|
| 418 |
+
color: #00ff00;
|
| 419 |
+
text-align: center;
|
| 420 |
+
}
|
| 421 |
+
h2, h3, h4 {
|
| 422 |
+
color: #ff7f50;
|
| 423 |
+
}
|
| 424 |
+
.tab {
|
| 425 |
+
background-color: #1d1d1d;
|
| 426 |
+
border: 1px solid #00ff00;
|
| 427 |
+
border-radius: 5px;
|
| 428 |
+
margin-bottom: 10px;
|
| 429 |
+
padding: 10px;
|
| 430 |
+
}
|
| 431 |
+
.tab:hover {
|
| 432 |
+
background-color: rgba(0, 255, 0, 0.2);
|
| 433 |
+
}
|
| 434 |
+
.warning {
|
| 435 |
+
background-color: rgba(255, 255, 0, 0.2);
|
| 436 |
+
color: #856404;
|
| 437 |
+
}
|
| 438 |
+
.error {
|
| 439 |
+
background-color: rgba(255, 0, 0, 0.3);
|
| 440 |
+
color: #721c24;
|
| 441 |
+
}
|
| 442 |
+
input[type="text"], input[type="file"] {
|
| 443 |
+
border: 2px solid #00ff00;
|
| 444 |
+
border-radius: 5px;
|
| 445 |
+
padding: 10px;
|
| 446 |
+
background-color: #1d1d1d;
|
| 447 |
+
color: #ffffff;
|
| 448 |
+
}
|
| 449 |
+
input[type="text"]:focus, input[type="file"]:focus {
|
| 450 |
+
border-color: #ff7f50;
|
| 451 |
+
outline: none;
|
| 452 |
+
}
|
| 453 |
+
.btn-primary {
|
| 454 |
+
background-color: #00ff00;
|
| 455 |
+
border: none;
|
| 456 |
+
border-radius: 5px;
|
| 457 |
+
padding: 10px 20px;
|
| 458 |
+
cursor: pointer;
|
| 459 |
+
transition: background-color 0.3s;
|
| 460 |
+
}
|
| 461 |
+
.btn-secondary {
|
| 462 |
+
background-color: #ff7f50;
|
| 463 |
+
border: none;
|
| 464 |
+
border-radius: 5px;
|
| 465 |
+
padding: 10px 20px;
|
| 466 |
+
cursor: pointer;
|
| 467 |
+
transition: background-color 0.3s;
|
| 468 |
+
}
|
| 469 |
+
.btn-primary:hover, .btn-secondary:hover {
|
| 470 |
+
background-color: rgba(255, 165, 0, 0.8);
|
| 471 |
+
}
|
| 472 |
+
textarea {
|
| 473 |
+
border: 2px solid #00ff00;
|
| 474 |
+
border-radius: 5px;
|
| 475 |
+
padding: 10px;
|
| 476 |
+
background-color: #1d1d1d;
|
| 477 |
+
color: #ffffff;
|
| 478 |
+
}
|
| 479 |
+
textarea:focus {
|
| 480 |
+
border-color: #ff7f50;
|
| 481 |
+
outline: none;
|
| 482 |
+
}
|
| 483 |
+
.output-box {
|
| 484 |
+
background-color: #1d1d1d;
|
| 485 |
+
border: 1px solid #00ff00;
|
| 486 |
+
border-radius: 5px;
|
| 487 |
+
padding: 10px;
|
| 488 |
+
overflow-x: auto;
|
| 489 |
+
}
|
| 490 |
+
"""
|
| 491 |
+
|
| 492 |
+
with gr.Blocks(css=css, title="Advanced Text & URL Processor") as interface:
|
| 493 |
+
gr.Markdown("# 🌐 Advanced URL & Text Processing Toolkit")
|
| 494 |
+
|
| 495 |
+
with gr.Tab("URL Processing"):
|
| 496 |
+
url_input = gr.Textbox(
|
| 497 |
+
label="Enter URLs (comma or newline separated)",
|
| 498 |
+
lines=5,
|
| 499 |
+
placeholder="https://example1.com\nhttps://example2.com",
|
| 500 |
+
interactive=True,
|
| 501 |
+
elem_id="url-input"
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
with gr.Tab("File Input"):
|
| 505 |
+
file_input = gr.File(
|
| 506 |
+
label="Upload text file or ZIP archive",
|
| 507 |
+
file_types=[".txt", ".zip", ".md", ".csv", ".json", ".xml"]
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
with gr.Tab("Text Input"):
|
| 511 |
+
text_input = gr.Textbox(
|
| 512 |
+
label="Raw Text Input",
|
| 513 |
+
lines=5,
|
| 514 |
+
placeholder="Paste your text here...",
|
| 515 |
+
interactive=True
|
| 516 |
+
)
|
| 517 |
+
|
| 518 |
+
with gr.Tab("JSON Editor"):
|
| 519 |
+
json_editor = gr.Textbox(
|
| 520 |
+
label="JSON Editor",
|
| 521 |
+
lines=20,
|
| 522 |
+
placeholder="View and edit your JSON data here...",
|
| 523 |
+
interactive=True,
|
| 524 |
+
elem_id="json-editor"
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
with gr.Tab("Scratchpad"):
|
| 528 |
+
scratchpad = gr.Textbox(
|
| 529 |
+
label="Scratchpad",
|
| 530 |
+
lines=10,
|
| 531 |
+
placeholder="Quick notes or text collections...",
|
| 532 |
+
interactive=True
|
| 533 |
+
)
|
| 534 |
+
|
| 535 |
+
process_btn = gr.Button("Process Input", variant="primary")
|
| 536 |
+
qr_btn = gr.Button("Generate QR Code", variant="secondary")
|
| 537 |
+
|
| 538 |
+
output_text = gr.Textbox(label="Processing Results", interactive=False, elem_id="output-text")
|
| 539 |
+
output_file = gr.File(label="Processed Output")
|
| 540 |
+
qr_output = gr.Image(label="QR Code", type="filepath") # To display the generated QR code
|
| 541 |
+
|
| 542 |
+
# The rest of the internal logic remains unchanged
|
| 543 |
+
|
| 544 |
+
gr.Markdown("""
|
| 545 |
+
### Usage Guidelines
|
| 546 |
+
- **URL Processing**: Enter valid HTTP/HTTPS URLs
|
| 547 |
+
- **File Input**: Upload text files or ZIP archives
|
| 548 |
+
- **Text Input**: Direct text processing
|
| 549 |
+
- **JSON Editor**: View and edit your JSON data
|
| 550 |
+
- **Scratchpad**: Quick notes or text collections
|
| 551 |
+
- Advanced cleaning and validation included
|
| 552 |
+
""")
|
| 553 |
+
|
| 554 |
+
return interface
|
| 555 |
|
| 556 |
def main():
|
| 557 |
# Configure system settings
|