Skip to content

Commit

Permalink
init lesson crud
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmdlt committed Aug 14, 2024
1 parent 6af4bc3 commit 6b5619d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 1 addition & 6 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def users_new():


@app.route('/users/<id>')
def show_user(id):
def users_show(id):
with open("./users.json", "r") as f:
users = json.load(f)
user = next(user for user in users if id == str(user['id']))
Expand All @@ -81,11 +81,6 @@ def show_user(id):
)


@app.route('/courses/<id>')
def courses(id):
return f'Course id: {id}'


def validate(user):
errors = {}
if not user['name']:
Expand Down
2 changes: 1 addition & 1 deletion templates/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ul>
{% for user in users %}
<li>Имя: <a href="{{ url_for('show_user', id=user.id)}}"> {{ user.name }}</a>, Email: {{ user.email}}</li>
<li>Имя: <a href="{{ url_for('users_show', id=user.id)}}"> {{ user.name }}</a>, Email: {{ user.email}}</li>
{% endfor %}
</ul>
{% endblock %}
8 changes: 7 additions & 1 deletion users.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
[{"id": 1, "name": "mike"}, {"id": 2, "name": "mishel"}, {"id": 3, "name": "adel"}, {"id": 4, "name": "keks"}, {"id": 5, "name": "kamila"}, {"id": "986e398a-b9ac-4195-bf40-bc85e57da274", "name": "dfdf", "email": "dfdgdgf"}, {"id": "4e409df7-c732-4075-a117-de013b464c69", "name": "13", "email": "34"}]
[
{ "id": 1, "name": "mike" },
{ "id": 2, "name": "mishel" },
{ "id": 3, "name": "adel" },
{ "id": 4, "name": "keks" },
{ "id": 5, "name": "kamila" }
]

0 comments on commit 6b5619d

Please sign in to comment.