mirror of
https://github.com/UofCBaja/BajaCloud.git
synced 2025-06-15 13:14: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 yaml
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from ReadDB import ReadDatabase
|
||||||
|
|
||||||
with open("./MockDB/schedule.yaml", "r") as scheduleyml:
|
with open("./MockDB/schedule.yaml", "r") as scheduleyml:
|
||||||
ymlschedule = yaml.safe_load(scheduleyml)
|
ymlschedule = yaml.safe_load(scheduleyml)
|
||||||
|
|
||||||
@ -17,8 +19,7 @@ def getSchedulePackager():
|
|||||||
``Contact``: darkicewolf50@gmail.ocm
|
``Contact``: darkicewolf50@gmail.ocm
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return {
|
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
|
from GetSchedulePackager import getSchedulePackager
|
||||||
|
|
||||||
@app.get("/getSchedule")
|
@app.get("/getAppointments")
|
||||||
async def getSchedule():
|
async def getAppointments():
|
||||||
|
|
||||||
res = getSchedulePackager()
|
res = getSchedulePackager()
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from WriteDB import AppendAppointment
|
from WriteDB import AppendAppointment
|
||||||
|
from email_validator import validate_email, EmailNotValidError
|
||||||
|
|
||||||
|
|
||||||
def SelectAppointment (appointmentJson):
|
def SelectAppointment (appointmentJson):
|
||||||
@ -15,17 +16,29 @@ def SelectAppointment (appointmentJson):
|
|||||||
|
|
||||||
``Contact``: darkicewolf50@gmail.com
|
``Contact``: darkicewolf50@gmail.com
|
||||||
"""
|
"""
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"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"])
|
status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
resBody = {"Success": True}
|
resBody = {"Success": True, "validEmail": "true"}
|
||||||
else:
|
else:
|
||||||
resBody = {"Success": False}
|
resBody = {"Success": False, "validEmail": "true"}
|
||||||
|
|
||||||
# resBody["message"] = appointmentJson for testing
|
# resBody["message"] = appointmentJson for testing
|
||||||
return resBody
|
return resBody
|
||||||
|
|
||||||
|
except EmailNotValidError as e:
|
||||||
|
return {"Success": False, "validEmail": "false"}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(SelectAppointment("10:00 AM"))
|
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.login(gmail_user, gmail_apppassword)
|
||||||
server.sendmail(gmail_user, [interviewee_email, static_email], msg.as_string())
|
server.sendmail(gmail_user, [interviewee_email, static_email], msg.as_string())
|
||||||
server.quit()
|
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:
|
except Exception as e:
|
||||||
print(f"Failed to send email: {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))
|
#print(json.dumps(res, indent=1))
|
||||||
|
|
||||||
def BenchMarkDjango():
|
def BenchMarkDjango():
|
||||||
rawRes = requests.get("http://localhost:8000/getSchedule")
|
rawRes = requests.get("http://127.0.0.1:8000/getAppointments")
|
||||||
res = json.loads(rawRes.text)
|
res = json.loads(rawRes.text)
|
||||||
# print(json.dumps(res, indent=1))
|
#print(json.dumps(res, indent=1))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test = 0
|
test = 1
|
||||||
if test:
|
if test:
|
||||||
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
|
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=1000)
|
||||||
pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
|
# pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
|
||||||
print(f"FastAPI: {djangoTime}\nPython: {pythonTime}")
|
print(f"FastAPI: {djangoTime}\nPython: ")
|
||||||
|
|
||||||
reqbody = {
|
reqbody = {
|
||||||
"body": {"message": "hello"}
|
"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