Skip to content

Commit

Permalink
Merge pull request #2 from suzu-devworks/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
suzu-devworks committed Jun 11, 2024
2 parents 01f1dd9 + 773f713 commit bb429ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Workspace for studying Python web programming.

[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
[![CodeQL](https://github.com/suzu-devworks/examples-py-web/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/suzu-devworks/examples-py-web/actions/workflows/github-code-scanning/codeql)


# What is this repository for?
Expand Down
2 changes: 1 addition & 1 deletion src/examples-flask-started/src/quickstart/_03_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def show_user_profile(username: str) -> str:
@app.route("/post/<int:post_id>")
def show_post(post_id: int) -> str:
# show the post with the given id, the id is an integer
return f"Post {post_id}"
return f"Post {escape(post_id)}"


@app.route("/path/<path:subpath>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"""

from flask import Flask, url_for
from markupsafe import escape

app = Flask(__name__)

Expand All @@ -38,7 +39,7 @@ def login() -> str:

@app.route("/user/<username>")
def profile(username: str) -> str:
return f"{username}'s profile"
return f"{escape(username)}'s profile"


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

from flask import Flask, Response, make_response, render_template, request
from markupsafe import escape
from werkzeug.utils import secure_filename

app = Flask(__name__)
Expand Down Expand Up @@ -60,7 +61,7 @@ def valid_login(username: str, password: str) -> bool:


def log_the_user_in(username: str) -> str:
return f"{username} is login."
return f"{escape(username)} is login."


"""
Expand All @@ -75,7 +76,7 @@ def upload_file() -> str:
file_name = secure_filename(str(file.filename))
print(f"save file to: uploads/{file_name}")
# file.save(f"uploads/{file_name}")
return f"OK: {file_name}, ({file.content_type})"
return f"OK: {escape(file_name)}, ({escape(file.content_type)})"


"""
Expand Down

0 comments on commit bb429ee

Please sign in to comment.