This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
1,201 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# UGent-2 | ||
[mockup](https://www.figma.com/file/py6Qk9lgFtzbCy9by2qsYU/SELab2?type=design&node-id=617%3A4348&mode=design&t=N4FQR50wAYEyG8qx-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: ruff-check | ||
name: ruff linting check | ||
entry: ruff check | ||
language: system | ||
types: [python] | ||
always_run: true | ||
- id: pyright | ||
name: pyright linting check | ||
entry: pyright | ||
language: system | ||
types: [python] | ||
always_run: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,61 @@ | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from starlette import status | ||
from starlette.requests import Request | ||
from starlette.responses import JSONResponse | ||
|
||
from db.errors.database_errors import ActionAlreadyPerformedError, ItemNotFoundError | ||
from routes.authentication import session_router | ||
from routes.teachers import teachers_router | ||
from routes.errors.authentication import InvalidRoleCredentialsError, StudentNotEnrolledError | ||
from routes.project import project_router | ||
from routes.student import student_router | ||
from routes.subject import subject_router | ||
from routes.teacher import teacher_router | ||
from routes.user import users_router | ||
|
||
app = FastAPI() | ||
|
||
# Koppel routes uit andere modules. | ||
app.include_router(teachers_router) | ||
app.include_router(session_router) | ||
app.include_router(session_router, prefix="/api") | ||
app.include_router(student_router, prefix="/api") | ||
app.include_router(teacher_router, prefix="/api") | ||
app.include_router(users_router, prefix="/api") | ||
app.include_router(project_router, prefix="/api") | ||
app.include_router(subject_router, prefix="/api") | ||
|
||
|
||
# Koppel de exception handlers | ||
@app.exception_handler(InvalidRoleCredentialsError) | ||
def invalid_admin_credentials_error_handler(request: Request, exc: InvalidRoleCredentialsError) -> JSONResponse: | ||
return JSONResponse( | ||
status_code=status.HTTP_403_FORBIDDEN, | ||
content={"message": exc.ERROR_MESSAGE}, | ||
) | ||
|
||
|
||
@app.exception_handler(ItemNotFoundError) | ||
def item_not_found_error_handler(request: Request, exc: ItemNotFoundError) -> JSONResponse: | ||
return JSONResponse( | ||
status_code=status.HTTP_404_NOT_FOUND, | ||
content={"detail": str(exc)}, | ||
) | ||
|
||
|
||
@app.exception_handler(StudentNotEnrolledError) | ||
def student_already_enrolled_error_handler(request: Request, exc: StudentNotEnrolledError) -> JSONResponse: | ||
return JSONResponse( | ||
status_code=status.HTTP_400_BAD_REQUEST, | ||
content={"detail": str(exc)}, | ||
) | ||
|
||
|
||
@app.exception_handler(ActionAlreadyPerformedError) | ||
def action_already_performed_error_handler(request: Request, exc: ActionAlreadyPerformedError) -> JSONResponse: | ||
return JSONResponse( | ||
status_code=status.HTTP_400_BAD_REQUEST, | ||
content={"detail": str(exc)}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
uvicorn.run("app:app") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.