diff --git a/__pycache__/GetSchedulePackager.cpython-313.pyc b/__pycache__/GetSchedulePackager.cpython-313.pyc index ab44533..15ad327 100644 Binary files a/__pycache__/GetSchedulePackager.cpython-313.pyc and b/__pycache__/GetSchedulePackager.cpython-313.pyc differ diff --git a/__pycache__/WriteDB.cpython-313.pyc b/__pycache__/WriteDB.cpython-313.pyc new file mode 100644 index 0000000..a93cb16 Binary files /dev/null and b/__pycache__/WriteDB.cpython-313.pyc differ diff --git a/__pycache__/main.cpython-313.pyc b/__pycache__/main.cpython-313.pyc new file mode 100644 index 0000000..4cbd1bc Binary files /dev/null and b/__pycache__/main.cpython-313.pyc differ diff --git a/__pycache__/newMain.cpython-313.pyc b/__pycache__/newMain.cpython-313.pyc index 8dd137b..d5bbeed 100644 Binary files a/__pycache__/newMain.cpython-313.pyc and b/__pycache__/newMain.cpython-313.pyc differ diff --git a/__pycache__/postSelectAppointment.cpython-313.pyc b/__pycache__/postSelectAppointment.cpython-313.pyc index e59725e..5993c88 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 new file mode 100644 index 0000000..a595e70 Binary files /dev/null and b/__pycache__/send_email.cpython-313.pyc differ diff --git a/djangotutorial/db.sqlite3 b/djangotutorial/db.sqlite3 deleted file mode 100644 index e69de29..0000000 diff --git a/djangotutorial/manage.py b/djangotutorial/manage.py deleted file mode 100755 index 8005262..0000000 --- a/djangotutorial/manage.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == "__main__": - main() diff --git a/djangotutorial/mysite/__init__.py b/djangotutorial/mysite/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/djangotutorial/mysite/__pycache__/__init__.cpython-312.pyc b/djangotutorial/mysite/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 86745d5..0000000 Binary files a/djangotutorial/mysite/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/getAppointments.cpython-312.pyc b/djangotutorial/mysite/__pycache__/getAppointments.cpython-312.pyc deleted file mode 100644 index 277ab79..0000000 Binary files a/djangotutorial/mysite/__pycache__/getAppointments.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/newtest.cpython-312.pyc b/djangotutorial/mysite/__pycache__/newtest.cpython-312.pyc deleted file mode 100644 index 9a423ca..0000000 Binary files a/djangotutorial/mysite/__pycache__/newtest.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/selectAppointment.cpython-312.pyc b/djangotutorial/mysite/__pycache__/selectAppointment.cpython-312.pyc deleted file mode 100644 index 037aa84..0000000 Binary files a/djangotutorial/mysite/__pycache__/selectAppointment.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/settings.cpython-312.pyc b/djangotutorial/mysite/__pycache__/settings.cpython-312.pyc deleted file mode 100644 index ca666c9..0000000 Binary files a/djangotutorial/mysite/__pycache__/settings.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/urls.cpython-312.pyc b/djangotutorial/mysite/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index 263b748..0000000 Binary files a/djangotutorial/mysite/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/__pycache__/wsgi.cpython-312.pyc b/djangotutorial/mysite/__pycache__/wsgi.cpython-312.pyc deleted file mode 100644 index 1e0c9af..0000000 Binary files a/djangotutorial/mysite/__pycache__/wsgi.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/asgi.py b/djangotutorial/mysite/asgi.py deleted file mode 100644 index 245a112..0000000 --- a/djangotutorial/mysite/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for mysite project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - -application = get_asgi_application() diff --git a/djangotutorial/mysite/getAppointments.py b/djangotutorial/mysite/getAppointments.py deleted file mode 100644 index 98e215b..0000000 --- a/djangotutorial/mysite/getAppointments.py +++ /dev/null @@ -1,8 +0,0 @@ -import json -from django.http import HttpResponse -from .methods.GetSchedulePackager import getSchedulePackager - - -def index(request): - res = getSchedulePackager() - return HttpResponse(json.dumps(res)) \ No newline at end of file diff --git a/djangotutorial/mysite/methods/GetSchedulePackager.py b/djangotutorial/mysite/methods/GetSchedulePackager.py deleted file mode 100644 index be00728..0000000 --- a/djangotutorial/mysite/methods/GetSchedulePackager.py +++ /dev/null @@ -1,26 +0,0 @@ -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) - } - diff --git a/djangotutorial/mysite/methods/MockDB/schedule.yaml b/djangotutorial/mysite/methods/MockDB/schedule.yaml deleted file mode 100644 index 2a85139..0000000 --- a/djangotutorial/mysite/methods/MockDB/schedule.yaml +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/djangotutorial/mysite/methods/__pycache__/GetSchedulePackager.cpython-312.pyc b/djangotutorial/mysite/methods/__pycache__/GetSchedulePackager.cpython-312.pyc deleted file mode 100644 index ad1658d..0000000 Binary files a/djangotutorial/mysite/methods/__pycache__/GetSchedulePackager.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/methods/__pycache__/postSelectAppointment.cpython-312.pyc b/djangotutorial/mysite/methods/__pycache__/postSelectAppointment.cpython-312.pyc deleted file mode 100644 index ec9dfb2..0000000 Binary files a/djangotutorial/mysite/methods/__pycache__/postSelectAppointment.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/mysite/methods/postSelectAppointment.py b/djangotutorial/mysite/methods/postSelectAppointment.py deleted file mode 100644 index 5a5688a..0000000 --- a/djangotutorial/mysite/methods/postSelectAppointment.py +++ /dev/null @@ -1,36 +0,0 @@ -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")) \ No newline at end of file diff --git a/djangotutorial/mysite/methods/schedule.yaml b/djangotutorial/mysite/methods/schedule.yaml deleted file mode 100644 index 2a85139..0000000 --- a/djangotutorial/mysite/methods/schedule.yaml +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/djangotutorial/mysite/newtest.py b/djangotutorial/mysite/newtest.py deleted file mode 100644 index 693c0df..0000000 --- a/djangotutorial/mysite/newtest.py +++ /dev/null @@ -1,47 +0,0 @@ -import json -from django.http import HttpResponse - -def index(request): - ymlschedule = {"message": False} - res = { - #"statusCode": 200, commented out because not needed django/wrapper will handle it - "isBase64ENcoded": "false", - "body": json.dumps(ymlschedule) - } - return HttpResponse(json.dumps(res), content_type='application/json') - ''' - response = HttpResponse(json.dumps(res), content_type='application/json') - response['X-IsBase64Encoded'] = 'false' # Custom header to indicate base64 encoding - response.status_code = 200 - return response - -from fastapi import FastAPI -from fastapi.responses import JSONResponse - -app = FastAPI() - -@app.get("/") -async def index(): - ymlschedule = {"message": False} - - # Create the response body with multiple items - res = { - "body": { - "Schedule": ymlschedule, # FastAPI will automatically serialize the dictionary - "message": "good", - } - } - - # Set custom headers - headers = { - "isBase64Encoded": "false", # Custom header - } - - # Return the response with the custom header - return JSONResponse( - content=res, - headers=headers, - # status_code=200 commented out just to show how to change it if you wanted - ) - - ''' diff --git a/djangotutorial/mysite/selectAppointment.py b/djangotutorial/mysite/selectAppointment.py deleted file mode 100644 index 15f2ec7..0000000 --- a/djangotutorial/mysite/selectAppointment.py +++ /dev/null @@ -1,8 +0,0 @@ -import json -from django.http import HttpResponse -from .methods.postSelectAppointment import SelectAppointment - - -def index(request): - res = SelectAppointment(request) - return HttpResponse(json.dumps(res)) \ No newline at end of file diff --git a/djangotutorial/mysite/settings.py b/djangotutorial/mysite/settings.py deleted file mode 100644 index 6e7457b..0000000 --- a/djangotutorial/mysite/settings.py +++ /dev/null @@ -1,123 +0,0 @@ -""" -Django settings for mysite project. - -Generated by 'django-admin startproject' using Django 5.1.3. - -For more information on this file, see -https://docs.djangoproject.com/en/5.1/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/5.1/ref/settings/ -""" - -from pathlib import Path - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-6&71dc8$=p0pg+5=7^_vk6_an^8o2mrr)gh1gs5#i56h)f2um6" - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", -] - -MIDDLEWARE = [ - "django.middleware.security.SecurityMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", -] - -ROOT_URLCONF = "mysite.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "mysite.wsgi.application" - - -# Database -# https://docs.djangoproject.com/en/5.1/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } -} - - -# Password validation -# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/5.1/topics/i18n/ - -LANGUAGE_CODE = "en-us" - -TIME_ZONE = "UTC" - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/5.1/howto/static-files/ - -STATIC_URL = "static/" - -# Default primary key field type -# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/djangotutorial/mysite/urls.py b/djangotutorial/mysite/urls.py deleted file mode 100644 index da52cf6..0000000 --- a/djangotutorial/mysite/urls.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -URL configuration for mysite project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" - -from django.contrib import admin -from django.urls import include, path -from . import newtest, getAppointments, selectAppointment - -urlpatterns = [ - path("polls/", include("polls.urls")), - path("admin/", admin.site.urls), - path("test", newtest.index, name="index"), - path("getSchedule", getAppointments.index, name="index"), - path("postSelectAppointment", selectAppointment.index, name="index"), -] \ No newline at end of file diff --git a/djangotutorial/mysite/wsgi.py b/djangotutorial/mysite/wsgi.py deleted file mode 100644 index 5dbe20a..0000000 --- a/djangotutorial/mysite/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for mysite project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - -application = get_wsgi_application() diff --git a/djangotutorial/polls/__init__.py b/djangotutorial/polls/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/djangotutorial/polls/__pycache__/__init__.cpython-312.pyc b/djangotutorial/polls/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index bf20d19..0000000 Binary files a/djangotutorial/polls/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/__pycache__/getAppointments.cpython-312.pyc b/djangotutorial/polls/__pycache__/getAppointments.cpython-312.pyc deleted file mode 100644 index 85a3af5..0000000 Binary files a/djangotutorial/polls/__pycache__/getAppointments.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/__pycache__/newtest.cpython-312.pyc b/djangotutorial/polls/__pycache__/newtest.cpython-312.pyc deleted file mode 100644 index 437ea5d..0000000 Binary files a/djangotutorial/polls/__pycache__/newtest.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/__pycache__/selectAppointment.cpython-312.pyc b/djangotutorial/polls/__pycache__/selectAppointment.cpython-312.pyc deleted file mode 100644 index b66a5a6..0000000 Binary files a/djangotutorial/polls/__pycache__/selectAppointment.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/__pycache__/urls.cpython-312.pyc b/djangotutorial/polls/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index e8793e8..0000000 Binary files a/djangotutorial/polls/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/__pycache__/views.cpython-312.pyc b/djangotutorial/polls/__pycache__/views.cpython-312.pyc deleted file mode 100644 index 9647f44..0000000 Binary files a/djangotutorial/polls/__pycache__/views.cpython-312.pyc and /dev/null differ diff --git a/djangotutorial/polls/admin.py b/djangotutorial/polls/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/djangotutorial/polls/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/djangotutorial/polls/apps.py b/djangotutorial/polls/apps.py deleted file mode 100644 index 5184937..0000000 --- a/djangotutorial/polls/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class PollsConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "polls" diff --git a/djangotutorial/polls/migrations/__init__.py b/djangotutorial/polls/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/djangotutorial/polls/models.py b/djangotutorial/polls/models.py deleted file mode 100644 index 71a8362..0000000 --- a/djangotutorial/polls/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/djangotutorial/polls/tests.py b/djangotutorial/polls/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/djangotutorial/polls/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/djangotutorial/polls/urls.py b/djangotutorial/polls/urls.py deleted file mode 100644 index 0cc22df..0000000 --- a/djangotutorial/polls/urls.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.urls import path - -from . import views -# , newtest, getAppointments, selectAppointment - - -urlpatterns = [ - path("", views.index, name="index"), - # path("test", newtest.index, name="index"), - # path("getSchedule", getAppointments.index, name="index"), - # path("postSelectAppointment", selectAppointment.index, name="index"), -] diff --git a/djangotutorial/polls/views.py b/djangotutorial/polls/views.py deleted file mode 100644 index d6d6f4b..0000000 --- a/djangotutorial/polls/views.py +++ /dev/null @@ -1,8 +0,0 @@ -# from django.shortcuts import render - -# # Create your views here. -from django.http import HttpResponse - - -def index(request): - return HttpResponse("Hello, world. You're at the polls index.") \ No newline at end of file diff --git a/interview_database.xlsx b/interview_database.xlsx index 68fc44d..f649e88 100644 Binary files a/interview_database.xlsx and b/interview_database.xlsx differ diff --git a/main.py b/main.py index ae4999f..10966e9 100644 --- a/main.py +++ b/main.py @@ -1,108 +1,72 @@ -from GetSchedulePackager import getSchedulePackager -from postSelectAppointment import SelectAppointment import json -import signal -import sys -from http.server import BaseHTTPRequestHandler, HTTPServer +from fastapi import FastAPI +from fastapi.responses import JSONResponse +from pydantic import BaseModel -# Define request handler -class RequestHandler(BaseHTTPRequestHandler): +app = FastAPI() - def do_GET(self): - """Handle GET requests and route based on path""" - if self.path == '/getAppointments': - self._send_response(getSchedulePackager()) - elif self.path == '/interview_data': - self._send_response(doNothing()) # If you want to return an empty response - else: - self._send_error(404, "Not Found") +@app.get("/") +def get_root(): + res = {"message": "Hello World"} - def do_POST(self): - """Handle POST requests to '/selectAppointment' or '/'""" - content_length = int(self.headers['Content-Length']) - post_data = self.rfile.read(content_length) - - # Try to parse JSON data from the request body - try: - json_data = json.loads(post_data.decode('utf-8')) - except json.JSONDecodeError: - self._send_error(400, "Invalid Request") - return - - if self.path == '/selectAppointment': - self._send_response(SelectAppointment(json_data)) # Use SelectAppointment directly - elif self.path == '/': - self._send_response(doNothing()) # Empty response for the root route - else: - self._send_error(404, "Not Found") - - def _send_response(self, res): - """Send the response body with the given status code""" - if isinstance(res, dict): - # Ensure res has all the required keys - body = res.get("body", "") # Default to empty string if no body is provided - baseEncoded = res.get("isBase64ENcoded", "false") # Default to "false" if not provided - status_code = res.get("statusCode", 200) # Default to 200 if no statusCode is provided - - # Convert body to string if it's not already - if isinstance(body, dict): - body = json.dumps(body) - - # If body is base64 encoded, we would handle that differently, but currently we treat all as 'false' + # Return the response with the custom header + return JSONResponse( + headers={ + "isBase64Encoded": "false", # Header Modification + }, + content={ + "body": res + }, - response = { - "statusCode": status_code, - "isBase64Encoded": baseEncoded, - "headers": { - "Content-Type": "application/json", # Specify content type - "X-IsBase64Encoded": baseEncoded # Indicating if the body is base64 encoded - }, - "body": body - } - - # Send the status code and headers - self.send_response(status_code) - self.send_header("Content-Type", "application/json") - self.end_headers() - - # Write the JSON response body, ensuring it's encoded to utf-8 - self.wfile.write(json.dumps(response).encode('utf-8')) - - def _send_error(self, status_code=404, message="Not Found"): - """Send error response with the same structure as normal responses""" - res = { - "statusCode": status_code, - "body": json.dumps({"message": message}) - } - # Return the error response in the same format - self._send_response(res) - -def doNothing(): - """Return an empty JSON response""" - return { - "statusCode": 200, - "isBase64ENcoded": "false", - "body": json.dumps({"message": ""}) - } + # status_code=200 commented out just to show how to change it if you wanted + ) -# Graceful shutdown handler -def signal_handler(sig, frame): - print("\nShutting down server gracefully...") - sys.exit(0) + # # Set headers + # headers = { + # "isBase64Encoded": "false", # Header Modification + # } -# Set up and start the server -if __name__ == "__main__": - # Register signal handler for graceful shutdown (e.g., Ctrl+C) - signal.signal(signal.SIGINT, signal_handler) +from GetSchedulePackager import getSchedulePackager - # Set the server address (localhost) and port (8080) - server_address = ('', 8080) - httpd = HTTPServer(server_address, RequestHandler) +@app.get("/getSchedule") +async def getSchedule(): + + res = getSchedulePackager() - print("Server started on port 8080") - try: - # Start the server and listen for requests - httpd.serve_forever() - except KeyboardInterrupt: - pass + return JSONResponse( + headers={ + "isBase64Encoded": "false", # Header Modification + }, + content={ + "body": res + }, + + # status_code=200 commented out just to show how to change it if you wanted + ) + +from postSelectAppointment import SelectAppointment + +class Appointment(BaseModel): + intervieweeName: str + date: str + startTime: str + intervieweeEmail: str + + +@app.post("/SelectInterview") +async def postSelectInterview(rawRequest: Appointment): + + requestDict = {key: str(value) for key, value in rawRequest.dict().items()} + res = SelectAppointment(requestDict) + + return JSONResponse( + headers={ + "isBase64Encoded": "false", # Header Modification + }, + content={ + "body": res + }, + + # status_code=200 commented out just to show how to change it if you wanted + ) \ No newline at end of file diff --git a/newMain.py b/newMain.py deleted file mode 100644 index 3a2fe57..0000000 --- a/newMain.py +++ /dev/null @@ -1,69 +0,0 @@ -import json -from fastapi import FastAPI -from fastapi.responses import JSONResponse -from pydantic import BaseModel - -app = FastAPI() - -@app.get("/") -def get_root(): - res = {"message": "Hello World"} - - # Return the response with the custom header - return JSONResponse( - headers={ - "isBase64Encoded": "false", # Header Modification - }, - content={ - "body": res - }, - - # status_code=200 commented out just to show how to change it if you wanted - ) - - - # # Set headers - # headers = { - # "isBase64Encoded": "false", # Header Modification - # } - -from GetSchedulePackager import getSchedulePackager - -@app.get("/getSchedule") -async def getSchedule(): - - res = getSchedulePackager() - - return JSONResponse( - headers={ - "isBase64Encoded": "false", # Header Modification - }, - content={ - "body": res - }, - - # status_code=200 commented out just to show how to change it if you wanted - ) - -from postSelectAppointment import SelectAppointment - -class Appointment(BaseModel): - name: str - date: str - -@app.post("/SelectInterview") -async def postSelectInterview(rawRequest: dict): - - - res = SelectAppointment(rawRequest) - - return JSONResponse( - headers={ - "isBase64Encoded": "false", # Header Modification - }, - content={ - "body": res - }, - - # status_code=200 commented out just to show how to change it if you wanted - ) \ No newline at end of file diff --git a/postSelectAppointment.py b/postSelectAppointment.py index 49bb918..5d92867 100644 --- a/postSelectAppointment.py +++ b/postSelectAppointment.py @@ -1,6 +1,5 @@ -import json -import datetime -import requests +from WriteDB import AppendAppointment + def SelectAppointment (appointmentJson): """ @@ -18,18 +17,15 @@ def SelectAppointment (appointmentJson): """ - status = mockWriteFunction(appointmentJson) + status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"]) if status: - resBody = {"Success": True, "message": ""} + resBody = {"Success": True} else: - resBody = {"Success": False, "message": ""} + resBody = {"Success": False} - resBody["message"] = appointmentJson["message"] + # resBody["message"] = appointmentJson for testing return resBody -def mockWriteFunction(appTime): - return 0 - if __name__ == "__main__": print(SelectAppointment("10:00 AM")) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..593f982 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +"fastapi[standard]" +pandas +openpyxl \ No newline at end of file diff --git a/send_email.py b/send_email.py index 736b75d..e450ac1 100644 --- a/send_email.py +++ b/send_email.py @@ -60,7 +60,11 @@ def send_email(interviewee_email="darkicewolf50@gmail.com", interviewee_name="br

Best regards,

UCalgary Baja Interview Team

- UCalgary Baja Team + UCalgary Baja Team ''' diff --git a/web1.html b/web1.html index 31da8f9..5049285 100644 --- a/web1.html +++ b/web1.html @@ -20,6 +20,10 @@

Best regards,

UCalgary Baja Interview Team

- UCalgary Baja Team + UCalgary Baja Team