diff --git a/Auth/__pycache__/AuthAPI.cpython-38.pyc b/Auth/__pycache__/AuthAPI.cpython-38.pyc new file mode 100644 index 0000000..9fd349b Binary files /dev/null and b/Auth/__pycache__/AuthAPI.cpython-38.pyc differ diff --git a/Auth/__pycache__/AuthAPI.cpython-39.pyc b/Auth/__pycache__/AuthAPI.cpython-39.pyc new file mode 100644 index 0000000..0801344 Binary files /dev/null and b/Auth/__pycache__/AuthAPI.cpython-39.pyc differ diff --git a/Profiles/ProfilesAPI.py b/Profiles/ProfilesAPI.py index 4467047..11a2684 100644 --- a/Profiles/ProfilesAPI.py +++ b/Profiles/ProfilesAPI.py @@ -5,3 +5,13 @@ sys.path.append("../") profiles_api = Blueprint("profiles", __name__) + + +@profiles_api.route('', methods = ["GET"]) +def get_one_profile(name): + userInput = input() + if userInput in db: + return db[userInput] + + else: + print("User does not exist") diff --git a/Profiles/__pycache__/ProfilesAPI.cpython-38.pyc b/Profiles/__pycache__/ProfilesAPI.cpython-38.pyc index f47262d..ff15fa8 100644 Binary files a/Profiles/__pycache__/ProfilesAPI.cpython-38.pyc and b/Profiles/__pycache__/ProfilesAPI.cpython-38.pyc differ diff --git a/Profiles/__pycache__/ProfilesAPI.cpython-39.pyc b/Profiles/__pycache__/ProfilesAPI.cpython-39.pyc new file mode 100644 index 0000000..cdf18ca Binary files /dev/null and b/Profiles/__pycache__/ProfilesAPI.cpython-39.pyc differ diff --git a/Profiles/__pycache__/db.cpython-38.pyc b/Profiles/__pycache__/db.cpython-38.pyc new file mode 100644 index 0000000..94c9ac9 Binary files /dev/null and b/Profiles/__pycache__/db.cpython-38.pyc differ diff --git a/Profiles/__pycache__/db.cpython-39.pyc b/Profiles/__pycache__/db.cpython-39.pyc new file mode 100644 index 0000000..8ef0bd1 Binary files /dev/null and b/Profiles/__pycache__/db.cpython-39.pyc differ diff --git a/Profiles/db.py b/Profiles/db.py new file mode 100644 index 0000000..777200b --- /dev/null +++ b/Profiles/db.py @@ -0,0 +1,11 @@ +# Simulated db +db = [{ + "name": "Nobel", + "scores": [1, 2, 3, 4, 5] +}, { + "name": "Richard", + "scores": [5, 4, 3, 2, 1] +}, { + "name": "Hui Hui", + "scores": [9, 29, 34] +}] diff --git a/README.md b/README.md index 08c35ed..4020509 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ Homewwork template for BE training lesson 2: Flask and web servers Setup a basic API to simulate a website that tracks profiles and scores for exams A simulated db is provided. Note that the db will not be updated between runs - In main: + In main: (DONE) GET / homepage that returns a welcome message + In profiles API (/profiles prefix) GET /{id} to retrieve the name and all scores of a profile POST /profiles to create a new profile (name only) diff --git a/__pycache__/db.cpython-38.pyc b/__pycache__/db.cpython-38.pyc index 1970f42..8882107 100644 Binary files a/__pycache__/db.cpython-38.pyc and b/__pycache__/db.cpython-38.pyc differ diff --git a/__pycache__/db.cpython-39.pyc b/__pycache__/db.cpython-39.pyc new file mode 100644 index 0000000..460817a Binary files /dev/null and b/__pycache__/db.cpython-39.pyc differ diff --git a/main.py b/main.py index fc7fbd4..73e6bba 100644 --- a/main.py +++ b/main.py @@ -4,9 +4,14 @@ from db import db -# Write your flask code here - app = Flask(__name__) +@app.route("/", methods = ["GET"]) +def welcome_message(): + return "Welcome Back" + app.register_blueprint(profiles_api, url_prefix="/profiles") app.register_blueprint(auth_api, url_prefix="/auth") + +if __name__ == "__main__": + app.run(debug = True) \ No newline at end of file