Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Auth/__pycache__/AuthAPI.cpython-38.pyc
Binary file not shown.
Binary file added Auth/__pycache__/AuthAPI.cpython-39.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions Profiles/ProfilesAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
sys.path.append("../")

profiles_api = Blueprint("profiles", __name__)


@profiles_api.route('<string:name>', methods = ["GET"])
def get_one_profile(name):
userInput = input()
if userInput in db:
return db[userInput]

else:
print("User does not exist")
Binary file modified Profiles/__pycache__/ProfilesAPI.cpython-38.pyc
Binary file not shown.
Binary file added Profiles/__pycache__/ProfilesAPI.cpython-39.pyc
Binary file not shown.
Binary file added Profiles/__pycache__/db.cpython-38.pyc
Binary file not shown.
Binary file added Profiles/__pycache__/db.cpython-39.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions Profiles/db.py
Original file line number Diff line number Diff line change
@@ -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]
}]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified __pycache__/db.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/db.cpython-39.pyc
Binary file not shown.
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)