mirror of
https://github.com/UofCBaja/Interview-Backend.git
synced 2025-06-15 13:24:19 -06:00
feat(django): failure django is not faster than base python, but is WAAAAAYYY EASIER to code in endpoints, and can work with nginx
This commit is contained in:
parent
8f59972e19
commit
0c60ffc5ed
BIN
AfterMergeCodeapceTestResults.png
Normal file
BIN
AfterMergeCodeapceTestResults.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
__pycache__/GetSchedulePackager.cpython-312.pyc
Normal file
BIN
__pycache__/GetSchedulePackager.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/postSelectAppointment.cpython-312.pyc
Normal file
BIN
__pycache__/postSelectAppointment.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
djangotutorial/mysite/__pycache__/newtest.cpython-312.pyc
Normal file
BIN
djangotutorial/mysite/__pycache__/newtest.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
djangotutorial/mysite/getAppointments.py
Normal file
8
djangotutorial/mysite/getAppointments.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import json
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from .methods.GetSchedulePackager import getSchedulePackager
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
res = getSchedulePackager()
|
||||||
|
return HttpResponse(json.dumps(res))
|
26
djangotutorial/mysite/methods/GetSchedulePackager.py
Normal file
26
djangotutorial/mysite/methods/GetSchedulePackager.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import yaml
|
||||||
|
import json
|
||||||
|
|
||||||
|
with open("./mysite/methods/MockDB/schedule.yaml", "r") as scheduleyml:
|
||||||
|
ymlschedule = yaml.safe_load(scheduleyml)
|
||||||
|
|
||||||
|
def getSchedulePackager():
|
||||||
|
"""
|
||||||
|
Formats and allows for the
|
||||||
|
|
||||||
|
``REQUIRES``: None
|
||||||
|
|
||||||
|
``PROMISES``: ``JSON`` http response ready
|
||||||
|
|
||||||
|
``Develop in part by``: Brock T
|
||||||
|
|
||||||
|
``Contact``: darkicewolf50@gmail.ocm
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
return {
|
||||||
|
"statusCode": 200,
|
||||||
|
"isBase64ENcoded": "false",
|
||||||
|
"body": json.dumps(ymlschedule)
|
||||||
|
}
|
||||||
|
|
11
djangotutorial/mysite/methods/MockDB/schedule.yaml
Normal file
11
djangotutorial/mysite/methods/MockDB/schedule.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Date:
|
||||||
|
Sept 16:
|
||||||
|
Meeting Duration: 30 min
|
||||||
|
Meeting Start Times:
|
||||||
|
- 10:00 am
|
||||||
|
- 10:30 am
|
||||||
|
- 11:00 am
|
||||||
|
- 11:30 am
|
||||||
|
- 1:00 pm
|
||||||
|
- 1:30 pm
|
||||||
|
- 2:00 pm
|
Binary file not shown.
Binary file not shown.
36
djangotutorial/mysite/methods/postSelectAppointment.py
Normal file
36
djangotutorial/mysite/methods/postSelectAppointment.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import json
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def SelectAppointment (appointmentJson):
|
||||||
|
"""
|
||||||
|
packages up a response for a http request
|
||||||
|
|
||||||
|
``appointmentJSON``: ``JSON``
|
||||||
|
The appointment date and time details
|
||||||
|
|
||||||
|
``returns``: ``json``
|
||||||
|
Returns the status of the booking confirmation
|
||||||
|
|
||||||
|
``Develop in part by``: Brock T
|
||||||
|
|
||||||
|
``Contact``: darkicewolf50@gmail.com
|
||||||
|
"""
|
||||||
|
|
||||||
|
status = mockWriteFunction(appointmentJson)
|
||||||
|
|
||||||
|
if status:
|
||||||
|
resBody = {"Success": True}
|
||||||
|
else:
|
||||||
|
resBody = {"Success": False}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"statusCode": 200,
|
||||||
|
"isBase64ENcoded": "false",
|
||||||
|
"body": json.dumps(resBody)
|
||||||
|
}
|
||||||
|
|
||||||
|
def mockWriteFunction(appTime):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(SelectAppointment("10:00 AM"))
|
11
djangotutorial/mysite/methods/schedule.yaml
Normal file
11
djangotutorial/mysite/methods/schedule.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Date:
|
||||||
|
Sept 16:
|
||||||
|
Meeting Duration: 30 min
|
||||||
|
Meeting Start Times:
|
||||||
|
- 10:00 am
|
||||||
|
- 10:30 am
|
||||||
|
- 11:00 am
|
||||||
|
- 11:30 am
|
||||||
|
- 1:00 pm
|
||||||
|
- 1:30 pm
|
||||||
|
- 2:00 pm
|
8
djangotutorial/mysite/selectAppointment.py
Normal file
8
djangotutorial/mysite/selectAppointment.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import json
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from .methods.postSelectAppointment import SelectAppointment
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
res = SelectAppointment(request)
|
||||||
|
return HttpResponse(json.dumps(res))
|
@ -17,8 +17,12 @@ Including another URLconf
|
|||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
from . import newtest, getAppointments, selectAppointment
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("polls/", include("polls.urls")),
|
path("polls/", include("polls.urls")),
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("test", newtest.index, name="index"),
|
||||||
|
path("getSchedule", getAppointments.index, name="index"),
|
||||||
|
path("postSelectAppointment", selectAppointment.index, name="index"),
|
||||||
]
|
]
|
Binary file not shown.
BIN
djangotutorial/polls/__pycache__/getAppointments.cpython-312.pyc
Normal file
BIN
djangotutorial/polls/__pycache__/getAppointments.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,9 +1,12 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
from . import newtest
|
# , newtest, getAppointments, selectAppointment
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("test", newtest.index, name="index")
|
# path("test", newtest.index, name="index"),
|
||||||
|
# path("getSchedule", getAppointments.index, name="index"),
|
||||||
|
# path("postSelectAppointment", selectAppointment.index, name="index"),
|
||||||
]
|
]
|
||||||
|
@ -3,14 +3,14 @@ import requests
|
|||||||
import timeit
|
import timeit
|
||||||
|
|
||||||
def BenchMarkServer():
|
def BenchMarkServer():
|
||||||
rawRes = requests.get("http://localhost:8080")
|
rawRes = requests.get("http://localhost:8080/getAppointments")
|
||||||
res = json.loads(rawRes.text)
|
res = json.loads(rawRes.text)
|
||||||
#print(json.dumps(res, indent=1))
|
#print(json.dumps(res, indent=1))
|
||||||
|
|
||||||
def BenchMarkDjango():
|
def BenchMarkDjango():
|
||||||
rawRes = requests.get("http://localhost:8000/polls/test")
|
rawRes = requests.get("http://localhost:8000/getSchedule")
|
||||||
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__":
|
||||||
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
|
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user