-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
126 lines (96 loc) · 3.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
import theme
import views
import auth
from typing import Optional
from fastapi import Request
from fastapi.responses import RedirectResponse
from starlette.middleware.base import BaseHTTPMiddleware
from nicegui import Client, app, ui
app.add_static_files('/static', 'static')
app.add_middleware(auth.AuthMiddleware)
passwords = {'user1': 'pass1', 'user2': 'pass2'}
@ui.page('/')
def index():
theme.GlobalMenu('dashboard')
views.adminDash()
@ui.page('/staff')
def staff():
theme.GlobalMenu('staff')
views.staffDash()
@ui.page('/doctors')
def doctors():
theme.GlobalMenu('doctors')
views.doctorsDash()
@ui.page('/View_doctor/{doctorName}')
def View_doctor(doctorName : str):
theme.GlobalMenu('doctors')
views.View_doctorDash(doctorName)
@ui.page('/appointments')
def appointments():
theme.GlobalMenu('appointments')
views.appointmentsDash()
@ui.page('/payments')
def appointments():
theme.GlobalMenu('payments')
views.paymentsDash()
@ui.page('/View_payment/{paymentId}')
def View_payment(paymentId : int):
theme.GlobalMenu('payments')
views.View_payment(paymentId)
@ui.page('/invoices')
def invoices():
theme.GlobalMenu('invoices')
views.invoicesDash()
@ui.page('/Create_invoice')
def Create_invoice():
theme.GlobalMenu('invoices')
views.Create_invoiceDash()
@ui.page('/View_invoice/{invoiceId}')
def View_invoice(invoiceId : str):
theme.GlobalMenu('invoices')
views.View_invoiceDash(invoiceId)
@ui.page('/services')
def services():
theme.GlobalMenu('services')
views.servicesDash()
@ui.page('/medicine')
def medicine():
theme.GlobalMenu('medicine')
views.medicineDash()
@ui.page('/patients')
def patients():
theme.GlobalMenu('patients')
views.patientsDash()
@ui.page('/Create_patient')
def Create_patient():
theme.GlobalMenu('patients')
views.Create_patientDash()
@ui.page('/View_patient/{patientid}')
def View_patient(patientid : str):
theme.GlobalMenu('patients')
views.View_patientDash(patientid)
@ui.page('/New_MedicalRecord/{patientid}')
def New_MedicalRecord(patientid : str):
theme.GlobalMenu('patients')
views.New_MedicalRecord(patientid)
@ui.page('/Edit_MedicalRecord/{patientid}/{recordId}')
def Edit_MedicalRecord(patientid : str,recordId : int):
theme.GlobalMenu('patients')
views.Edit_MedicalRecord(patientid,recordId)
@ui.page('/login')
def login() -> Optional[RedirectResponse]:
def try_login() -> None: # local function to avoid passing username and password as arguments
if passwords.get(username.value) == password.value:
app.storage.user.update({'username': username.value, 'authenticated': True})
ui.navigate.to(app.storage.user.get('referrer_path', '/')) # go back to where the user wanted to go
else:
ui.notify('Wrong username or password', color='negative')
if app.storage.user.get('authenticated', False):
return RedirectResponse('/')
with ui.card().classes('absolute-center'):
username = ui.input('Username').on('keydown.enter', try_login)
password = ui.input('Password', password=True, password_toggle_button=True).on('keydown.enter', try_login)
ui.button('Log in', on_click=try_login)
return None
ui.run(storage_secret='THIS_NEEDS_TO_BE_CHANGED')