mirror of
https://github.com/UofCBaja/BajaCloud.git
synced 2025-06-15 05:04:17 -06:00
feat(putTogether): read db also combined
This commit is contained in:
parent
838e53905a
commit
76632341e5
@ -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()
|
||||
}
|
||||
|
||||
|
Binary file not shown.
BIN
__pycache__/ReadDB.cpython-313.pyc
Normal file
BIN
__pycache__/ReadDB.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
main.py
4
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()
|
||||
|
||||
|
@ -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"))
|
@ -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}")
|
||||
|
||||
|
14
testhttp.py
14
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user