Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -477,49 +477,37 @@ body, .gradio-container {
|
|
| 477 |
}
|
| 478 |
"""
|
| 479 |
|
| 480 |
-
# Create the interface with
|
| 481 |
def create_interface():
|
| 482 |
with gr.Blocks(css=modern_css, title="Python to C++ Code Optimizer", theme=gr.themes.Soft()) as app:
|
| 483 |
-
|
| 484 |
-
BANNER_URL = os.getenv("BANNER_URL", "")
|
| 485 |
-
BACKGROUND_URL = os.getenv("BACKGROUND_URL", "")
|
| 486 |
-
# Intentionally not rendering a banner image to avoid empty placeholders
|
| 487 |
-
|
| 488 |
def check_password(pw):
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
gr.update(visible=
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
# Login gate
|
| 497 |
-
with gr.Group(visible=True) as login_group:
|
| 498 |
gr.HTML("""
|
| 499 |
-
<div
|
| 500 |
-
<div
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
""")
|
| 505 |
pw = gr.Textbox(
|
| 506 |
-
label="Password",
|
| 507 |
-
type="password",
|
| 508 |
-
placeholder="Enter password",
|
| 509 |
-
|
| 510 |
container=True
|
| 511 |
)
|
| 512 |
-
login_btn = gr.Button("Continue",
|
| 513 |
-
login_error = gr.Markdown(visible=False
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
</div>
|
| 518 |
-
""")
|
| 519 |
-
|
| 520 |
-
# Main UI wrapped for toggling visibility
|
| 521 |
-
with gr.Group(visible=False) as main_group:
|
| 522 |
-
main_group.elem_id = "main_group"
|
| 523 |
# Header Section
|
| 524 |
gr.HTML("""
|
| 525 |
<div class="modern-header">
|
|
@@ -613,8 +601,8 @@ def create_interface():
|
|
| 613 |
inputs=cpp_output,
|
| 614 |
outputs=cpp_execution_output
|
| 615 |
)
|
| 616 |
-
|
| 617 |
-
#
|
| 618 |
login_btn.click(
|
| 619 |
fn=check_password,
|
| 620 |
inputs=[pw],
|
|
@@ -638,7 +626,7 @@ if __name__ == "__main__":
|
|
| 638 |
if is_huggingface:
|
| 639 |
# Hugging Face Spaces configuration
|
| 640 |
print("π Launching Python to C++ Code Optimizer on Hugging Face Spaces")
|
| 641 |
-
print("π
|
| 642 |
app.launch(
|
| 643 |
show_error=True
|
| 644 |
)
|
|
@@ -658,7 +646,7 @@ if __name__ == "__main__":
|
|
| 658 |
|
| 659 |
port = get_available_port()
|
| 660 |
print(f"π Launching Python to C++ Code Optimizer on port: {port}")
|
| 661 |
-
print(f"π
|
| 662 |
|
| 663 |
app.launch(
|
| 664 |
server_name="127.0.0.1",
|
|
|
|
| 477 |
}
|
| 478 |
"""
|
| 479 |
|
| 480 |
+
# Create the interface with custom login that SHOWS the boxes
|
| 481 |
def create_interface():
|
| 482 |
with gr.Blocks(css=modern_css, title="Python to C++ Code Optimizer", theme=gr.themes.Soft()) as app:
|
| 483 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
def check_password(pw):
|
| 485 |
+
if pw == APP_PASSWORD:
|
| 486 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 487 |
+
else:
|
| 488 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(value="β Wrong password", visible=True)
|
| 489 |
+
|
| 490 |
+
# Login Section - NO HTML wrapper around Gradio components!
|
| 491 |
+
with gr.Column(visible=True, elem_classes=["login-wrapper"]) as login_group:
|
|
|
|
|
|
|
| 492 |
gr.HTML("""
|
| 493 |
+
<div style="text-align: center; margin: 60px auto 40px; max-width: 400px;">
|
| 494 |
+
<div style="font-size: 56px; margin-bottom: 16px;">π</div>
|
| 495 |
+
<div style="font-size: 28px; font-weight: 700; color: #1f2937; margin-bottom: 8px;">Private Access</div>
|
| 496 |
+
<div style="font-size: 15px; color: #6b7280; margin-bottom: 32px;">Enter password to continue</div>
|
| 497 |
+
</div>
|
| 498 |
""")
|
| 499 |
pw = gr.Textbox(
|
| 500 |
+
label="Password",
|
| 501 |
+
type="password",
|
| 502 |
+
placeholder="Enter password",
|
| 503 |
+
scale=1,
|
| 504 |
container=True
|
| 505 |
)
|
| 506 |
+
login_btn = gr.Button("Continue", variant="primary", size="lg")
|
| 507 |
+
login_error = gr.Markdown("", visible=False)
|
| 508 |
+
|
| 509 |
+
# Main App Section
|
| 510 |
+
with gr.Column(visible=False) as main_group:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
# Header Section
|
| 512 |
gr.HTML("""
|
| 513 |
<div class="modern-header">
|
|
|
|
| 601 |
inputs=cpp_output,
|
| 602 |
outputs=cpp_execution_output
|
| 603 |
)
|
| 604 |
+
|
| 605 |
+
# Connect login button
|
| 606 |
login_btn.click(
|
| 607 |
fn=check_password,
|
| 608 |
inputs=[pw],
|
|
|
|
| 626 |
if is_huggingface:
|
| 627 |
# Hugging Face Spaces configuration
|
| 628 |
print("π Launching Python to C++ Code Optimizer on Hugging Face Spaces")
|
| 629 |
+
print("π Custom in-app password protection enabled")
|
| 630 |
app.launch(
|
| 631 |
show_error=True
|
| 632 |
)
|
|
|
|
| 646 |
|
| 647 |
port = get_available_port()
|
| 648 |
print(f"π Launching Python to C++ Code Optimizer on port: {port}")
|
| 649 |
+
print(f"π Custom in-app password protection enabled. Password: {APP_PASSWORD}")
|
| 650 |
|
| 651 |
app.launch(
|
| 652 |
server_name="127.0.0.1",
|