Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,52 +53,48 @@ def create_doctor(full_name, email, matricule, password, specialty):
|
|
| 53 |
except Exception as e:
|
| 54 |
return f"❌ Network Error: {str(e)}"
|
| 55 |
|
| 56 |
-
# Define Gradio interface
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
"
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
email
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
label="Specialty",
|
| 83 |
-
choices=["Cardiology", "Neurology", "Pediatrics", "Oncology", "General Practice", "Psychiatry", "Dermatology", "Orthopedics"],
|
| 84 |
-
value="Cardiology"
|
| 85 |
-
)
|
| 86 |
-
password = gr.Textbox(label="Password", type="password", placeholder="Secure password")
|
| 87 |
-
submit_btn = gr.Button("Create Doctor Account")
|
| 88 |
-
output = gr.Textbox(label="", show_label=False, elem_classes=["output-box"])
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
inputs=[full_name, email, matricule, specialty, password],
|
| 93 |
-
outputs=output
|
| 94 |
-
)
|
| 95 |
-
return admin_ui
|
| 96 |
|
| 97 |
-
# Mount Gradio at /admin
|
| 98 |
if __name__ == "__main__":
|
| 99 |
logger.debug("Running main block")
|
| 100 |
-
admin_ui = setup_gradio()
|
| 101 |
-
app = gr.mount_gradio_app(app, admin_ui, path="/admin")
|
| 102 |
-
logger.debug("Gradio mounted, starting app")
|
| 103 |
import uvicorn
|
| 104 |
-
uvicorn.run(app, host="0.0.0.0", port=7860) #
|
|
|
|
| 53 |
except Exception as e:
|
| 54 |
return f"❌ Network Error: {str(e)}"
|
| 55 |
|
| 56 |
+
# Define Gradio interface
|
| 57 |
+
with gr.Blocks(css="""
|
| 58 |
+
.gradio-container {
|
| 59 |
+
background-color: #1A1B1F;
|
| 60 |
+
color: #E2E8F0;
|
| 61 |
+
font-family: 'Segoe UI', sans-serif;
|
| 62 |
+
padding: 3rem;
|
| 63 |
+
}
|
| 64 |
+
.title-text { text-align: center; font-size: 2rem; font-weight: 700; color: #37B6E9; margin-bottom: 0.5rem; }
|
| 65 |
+
.description-text { text-align: center; font-size: 1rem; color: #A0AEC0; margin-bottom: 2rem; }
|
| 66 |
+
.gr-box, .gr-form, .gr-column, .gr-panel { background-color: #2D2F36 !important; border-radius: 16px !important; padding: 2rem !important; max-width: 600px; margin: auto; box-shadow: 0 0 0 1px #3B3E47; }
|
| 67 |
+
label { font-weight: 600; color: #F7FAFC; margin-bottom: 6px; }
|
| 68 |
+
input, select, textarea { background-color: #1A1B1F !important; color: #F7FAFC !important; border: 1px solid #4A5568 !important; font-size: 14px; padding: 10px; border-radius: 10px; }
|
| 69 |
+
button { background-color: #37B6E9 !important; color: #1A1B1F !important; border-radius: 10px !important; font-weight: 600; padding: 12px; width: 100%; margin-top: 1.5rem; }
|
| 70 |
+
.output-box textarea { background-color: transparent !important; border: none; color: #90CDF4; font-size: 14px; margin-top: 1rem; }
|
| 71 |
+
""") as admin_ui:
|
| 72 |
+
gr.Markdown("<div class='title-text'>👨⚕️ Doctor Account Creator</div>")
|
| 73 |
+
gr.Markdown("<div class='description-text'>Admins can register new doctors using this secure panel. Generated at 03:43 PM CET on Saturday, May 17, 2025.</div>")
|
| 74 |
+
|
| 75 |
+
with gr.Column():
|
| 76 |
+
full_name = gr.Textbox(label="Full Name", placeholder="e.g. Dr. Sarah Hopkins")
|
| 77 |
+
email = gr.Textbox(label="Email", placeholder="e.g. doctor@clinic.org")
|
| 78 |
+
matricule = gr.Textbox(label="Matricule", placeholder="e.g. DOC-1234")
|
| 79 |
+
specialty = gr.Dropdown(
|
| 80 |
+
label="Specialty",
|
| 81 |
+
choices=["Cardiology", "Neurology", "Pediatrics", "Oncology", "General Practice", "Psychiatry", "Dermatology", "Orthopedics"],
|
| 82 |
+
value="Cardiology"
|
| 83 |
+
)
|
| 84 |
+
password = gr.Textbox(label="Password", type="password", placeholder="Secure password")
|
| 85 |
+
submit_btn = gr.Button("Create Doctor Account")
|
| 86 |
+
output = gr.Textbox(label="", show_label=False, elem_classes=["output-box"])
|
| 87 |
|
| 88 |
+
submit_btn.click(
|
| 89 |
+
fn=create_doctor,
|
| 90 |
+
inputs=[full_name, email, matricule, specialty, password],
|
| 91 |
+
outputs=output
|
| 92 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
# Mount Gradio interface to FastAPI app
|
| 95 |
+
app = gr.mount_gradio_app(app, admin_ui, path="/admin")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
|
|
|
| 97 |
if __name__ == "__main__":
|
| 98 |
logger.debug("Running main block")
|
|
|
|
|
|
|
|
|
|
| 99 |
import uvicorn
|
| 100 |
+
uvicorn.run(app, host="0.0.0.0", port=7860) # For local testing
|