This repository has been archived by the owner on Jan 22, 2025. 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
10 changed files
with
51 additions
and
153 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
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,4 @@ | ||
flask~=3.0.2 | ||
flask-restful | ||
python-dotenv~=1.0.1 | ||
psycopg2-binary |
This file was deleted.
Oops, something went wrong.
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,10 +1,48 @@ | ||
"""Main entry point for the application.""" | ||
|
||
from dotenv import load_dotenv | ||
from test_auth_server import create_app_with_db | ||
from test_auth_server.db_in import url | ||
from flask import Flask | ||
|
||
"""Index api point""" | ||
from flask import Blueprint, request | ||
from flask_restful import Resource, Api | ||
|
||
index_bp = Blueprint("index", __name__) | ||
index_endpoint = Api(index_bp) | ||
|
||
token_dict = { | ||
"teacher1":{ | ||
"id":"brinkmann", | ||
"jobCategory":"teacher" | ||
}, | ||
"teacher2":{ | ||
"id":"laermans", | ||
"jobCategory":"teacher" | ||
} | ||
} | ||
|
||
class Index(Resource): | ||
"""Api endpoint for the / route""" | ||
|
||
def get(self): | ||
auth = request.headers.get("Authorization") | ||
if not auth: | ||
return {"message":"Please give authorization"}, 401 | ||
bearer, token = auth.split(" ") | ||
if bearer != "Bearer": | ||
return {"message":"Not this kind of authorization"}, 401 | ||
if token in token_dict.keys(): | ||
return token_dict[token], 200 | ||
return {"message":"Wrong address"}, 401 | ||
|
||
|
||
index_bp.add_url_rule("/", view_func=Index.as_view("index")) | ||
|
||
if __name__ == "__main__": | ||
load_dotenv() | ||
app = create_app_with_db(url) | ||
app.run(debug=True, host='0.0.0.0') | ||
|
||
app = Flask(__name__) | ||
app.register_blueprint(index_bp) | ||
|
||
app.run(debug=True, host='0.0.0.0') | ||
|
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 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