Ali2206 commited on
Commit
e92bd62
·
verified ·
1 Parent(s): b7c0a0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -43
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 as a separate function
57
- def setup_gradio():
58
- logger.debug("Setting up Gradio interface")
59
- with gr.Blocks(css="""
60
- .gradio-container {
61
- background-color: #1A1B1F;
62
- color: #E2E8F0;
63
- font-family: 'Segoe UI', sans-serif;
64
- padding: 3rem;
65
- }
66
- .title-text { text-align: center; font-size: 2rem; font-weight: 700; color: #37B6E9; margin-bottom: 0.5rem; }
67
- .description-text { text-align: center; font-size: 1rem; color: #A0AEC0; margin-bottom: 2rem; }
68
- .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; }
69
- label { font-weight: 600; color: #F7FAFC; margin-bottom: 6px; }
70
- input, select, textarea { background-color: #1A1B1F !important; color: #F7FAFC !important; border: 1px solid #4A5568 !important; font-size: 14px; padding: 10px; border-radius: 10px; }
71
- button { background-color: #37B6E9 !important; color: #1A1B1F !important; border-radius: 10px !important; font-weight: 600; padding: 12px; width: 100%; margin-top: 1.5rem; }
72
- .output-box textarea { background-color: transparent !important; border: none; color: #90CDF4; font-size: 14px; margin-top: 1rem; }
73
- """) as admin_ui:
74
- gr.Markdown("<div class='title-text'>👨‍⚕️ Doctor Account Creator</div>")
75
- 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>")
 
 
 
 
 
 
 
 
 
 
 
76
 
77
- with gr.Column():
78
- full_name = gr.Textbox(label="Full Name", placeholder="e.g. Dr. Sarah Hopkins")
79
- email = gr.Textbox(label="Email", placeholder="e.g. doctor@clinic.org")
80
- matricule = gr.Textbox(label="Matricule", placeholder="e.g. DOC-1234")
81
- specialty = gr.Dropdown(
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
- submit_btn.click(
91
- fn=create_doctor,
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) # Hugging Face Spaces default port
 
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