1 Commits

Author SHA1 Message Date
63059233da Create test.txt 2024-12-29 14:55:03 -07:00
3 changed files with 3 additions and 38 deletions

View File

@ -5,7 +5,7 @@ The Docker Project that runs on the Baja Nas
# BAJA CLoud Backend # BAJA CLoud Backend
Can be found [here](https://bajabackend.bajacloud.duckdns.org/) Can be found [here](http://darkicewofl50.asuscomm.com:43443/)
Reason in "Baja Data 2024 - 2025/W - Software/Brock's Learning.docx" Reason in "Baja Data 2024 - 2025/W - Software/Brock's Learning.docx"

38
main.py
View File

@ -1,6 +1,5 @@
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel from pydantic import BaseModel
from InterviewBooking.NoSheet import NoSheet from InterviewBooking.NoSheet import NoSheet
@ -15,32 +14,8 @@ if not os.path.isfile(file_name):
os.makedirs(os.path.dirname(file_name), exist_ok=True) os.makedirs(os.path.dirname(file_name), exist_ok=True)
NoSheet(file_name) NoSheet(file_name)
app = FastAPI() app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # This allows all origins
allow_credentials=True,
allow_methods=["*"], # Allow all methods (GET, POST, OPTIONS, etc.)
allow_headers=["*"], # Allow all headers
)
"""
YOU MUST ADD CORS MANUALLY TO ANY METHOD USE THIS TEMPLATE
ADD TO JSONRESPONSE
USE APPROPRIATE METHOD fOR THE TYPE IE
@app.get = ... "Access-Control-Allow-Methods": "GET", ...
headers={
"isBase64Encoded": "false", # Header Modification
# Adding CORS headers explicitly
"Access-Control-Allow-Origin": "*", # Allow all origins
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", # Allowed methods
"Access-Control-Allow-Headers": "*", # Allow all headers
},
"""
@app.get("/") @app.get("/")
def get_root(): def get_root():
""" """
@ -62,9 +37,6 @@ def get_root():
return JSONResponse( return JSONResponse(
headers={ headers={
"isBase64Encoded": "false", # Header Modification "isBase64Encoded": "false", # Header Modification
"Access-Control-Allow-Origin": "*", # Allow all origins
"Access-Control-Allow-Methods": "GET", # Allowed methods
"Access-Control-Allow-Headers": "*", # Allow all headers
}, },
content={ content={
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified "body": res # Ensure res is a dict or do json.dumps to enusre it is stringified
@ -96,10 +68,6 @@ async def getAppointments():
return JSONResponse( return JSONResponse(
headers={ headers={
"isBase64Encoded": "false", # Header Modification "isBase64Encoded": "false", # Header Modification
# Adding CORS headers explicitly
"Access-Control-Allow-Origin": "*", # Allow all origins
"Access-Control-Allow-Methods": "GET", # Allowed methods
"Access-Control-Allow-Headers": "*", # Allow all headers
}, },
content={ content={
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified "body": res # Ensure res is a dict or do json.dumps to enusre it is stringified
@ -124,8 +92,8 @@ class Appointment(BaseModel):
""" """
intervieweeName: str intervieweeName: str
startTime: str
date: str date: str
startTime: str
intervieweeEmail: str intervieweeEmail: str
@ -150,10 +118,6 @@ async def postSelectInterview(rawRequest: Appointment):
return JSONResponse( return JSONResponse(
headers={ headers={
"isBase64Encoded": "false", # Header Modification "isBase64Encoded": "false", # Header Modification
# Adding CORS headers explicitly
"Access-Control-Allow-Origin": "*", # Allow all origins
"Access-Control-Allow-Methods": "POST", # Allowed methods
"Access-Control-Allow-Headers": "*", # Allow all headers
}, },
content={ content={
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified "body": res # Ensure res is a dict or do json.dumps to enusre it is stringified

1
test.txt Normal file
View File

@ -0,0 +1 @@
this is only to test a discord webhook, this will be deleted later