diff --git a/GetSchedulePackager.py b/GetSchedulePackager.py index 47ce8c4..6e85fd7 100644 --- a/GetSchedulePackager.py +++ b/GetSchedulePackager.py @@ -1,6 +1,8 @@ import yaml import json +from ReadDB import ReadDatabase + with open("./MockDB/schedule.yaml", "r") as scheduleyml: ymlschedule = yaml.safe_load(scheduleyml) @@ -17,8 +19,7 @@ def getSchedulePackager(): ``Contact``: darkicewolf50@gmail.ocm """ - return { - "interviewDates": json.dumps(ymlschedule) + "interviewDates": ReadDatabase() } diff --git a/__pycache__/GetSchedulePackager.cpython-313.pyc b/__pycache__/GetSchedulePackager.cpython-313.pyc index 15ad327..33a56b0 100644 Binary files a/__pycache__/GetSchedulePackager.cpython-313.pyc and b/__pycache__/GetSchedulePackager.cpython-313.pyc differ diff --git a/__pycache__/ReadDB.cpython-313.pyc b/__pycache__/ReadDB.cpython-313.pyc new file mode 100644 index 0000000..6517ae0 Binary files /dev/null and b/__pycache__/ReadDB.cpython-313.pyc differ diff --git a/__pycache__/WriteDB.cpython-313.pyc b/__pycache__/WriteDB.cpython-313.pyc index a93cb16..f2c7f95 100644 Binary files a/__pycache__/WriteDB.cpython-313.pyc and b/__pycache__/WriteDB.cpython-313.pyc differ diff --git a/__pycache__/main.cpython-313.pyc b/__pycache__/main.cpython-313.pyc index 4cbd1bc..84981fb 100644 Binary files a/__pycache__/main.cpython-313.pyc and b/__pycache__/main.cpython-313.pyc differ diff --git a/__pycache__/postSelectAppointment.cpython-313.pyc b/__pycache__/postSelectAppointment.cpython-313.pyc index 5993c88..371fd80 100644 Binary files a/__pycache__/postSelectAppointment.cpython-313.pyc and b/__pycache__/postSelectAppointment.cpython-313.pyc differ diff --git a/__pycache__/send_email.cpython-313.pyc b/__pycache__/send_email.cpython-313.pyc index a595e70..def618d 100644 Binary files a/__pycache__/send_email.cpython-313.pyc and b/__pycache__/send_email.cpython-313.pyc differ diff --git a/interview_database.xlsx b/interview_database.xlsx index f649e88..69e0caf 100644 Binary files a/interview_database.xlsx and b/interview_database.xlsx differ diff --git a/main.py b/main.py index 10966e9..07a7486 100644 --- a/main.py +++ b/main.py @@ -29,8 +29,8 @@ def get_root(): from GetSchedulePackager import getSchedulePackager -@app.get("/getSchedule") -async def getSchedule(): +@app.get("/getAppointments") +async def getAppointments(): res = getSchedulePackager() diff --git a/postSelectAppointment.py b/postSelectAppointment.py index 5d92867..475c07f 100644 --- a/postSelectAppointment.py +++ b/postSelectAppointment.py @@ -1,4 +1,5 @@ from WriteDB import AppendAppointment +from email_validator import validate_email, EmailNotValidError def SelectAppointment (appointmentJson): @@ -15,17 +16,29 @@ def SelectAppointment (appointmentJson): ``Contact``: darkicewolf50@gmail.com """ - - - status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"]) - - if status: - resBody = {"Success": True} - else: - resBody = {"Success": False} - - # resBody["message"] = appointmentJson for testing - return resBody + """ + { + "intervieweeName": "Alice Johnson", + "date": "2024-09-16", + "startTime": "10:30:00", + "intervieweeEmail": "darkicewolf50@gmail.com" + } + """ + try: + validEmail = validate_email(appointmentJson["intervieweeEmail"], check_deliverability=True) + if validEmail: + status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"]) + + if status: + resBody = {"Success": True, "validEmail": "true"} + else: + resBody = {"Success": False, "validEmail": "true"} + + # resBody["message"] = appointmentJson for testing + return resBody + + except EmailNotValidError as e: + return {"Success": False, "validEmail": "false"} if __name__ == "__main__": print(SelectAppointment("10:00 AM")) \ No newline at end of file diff --git a/send_email.py b/send_email.py index e450ac1..888ce36 100644 --- a/send_email.py +++ b/send_email.py @@ -78,7 +78,7 @@ def send_email(interviewee_email="darkicewolf50@gmail.com", interviewee_name="br server.login(gmail_user, gmail_apppassword) server.sendmail(gmail_user, [interviewee_email, static_email], msg.as_string()) server.quit() - print(f"Email sent successfully to {interviewee_email} and {static_email}.") + # print(f"Email sent successfully to {interviewee_email} and {static_email}.") except Exception as e: print(f"Failed to send email: {e}") diff --git a/testhttp.py b/testhttp.py index ff7d9c0..d65f6d4 100644 --- a/testhttp.py +++ b/testhttp.py @@ -8,18 +8,18 @@ def BenchMarkServer(): #print(json.dumps(res, indent=1)) def BenchMarkDjango(): - rawRes = requests.get("http://localhost:8000/getSchedule") + rawRes = requests.get("http://127.0.0.1:8000/getAppointments") res = json.loads(rawRes.text) - # print(json.dumps(res, indent=1)) + #print(json.dumps(res, indent=1)) if __name__ == "__main__": - test = 0 + test = 1 if test: - djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10) - pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10) - print(f"FastAPI: {djangoTime}\nPython: {pythonTime}") + djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=1000) + # pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10) + print(f"FastAPI: {djangoTime}\nPython: ") reqbody = { "body": {"message": "hello"} } - rawRes = requests.post("http://localhost:8000/SelectInterview", reqbody) + # rawRes = requests.post("http://localhost:8000/SelectInterview", reqbody)