Skip to content

Commit 573b8e4

Browse files
committed
Refactor docstring and add todos
- Update docstring for `try_hack_me` to reflect public IP response - Add TODO comments for template injection tests - Adjust `FIXME` comment for `HTMLResponse` in `main.py`
1 parent 7b8f313 commit 573b8e4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def try_hack_me(name: str = config.SUPER_SECRET_NAME):
2424
name (str, optional): Name of the user. Defaults to SUPER_SECRET_NAME.
2525
2626
Returns:
27-
str: HTML content with a greeting and a random text.
27+
str: HTML content with a greeting and a public ip response.
2828
"""
2929
try:
3030
# Get the public IP address from an external service
@@ -36,5 +36,6 @@ async def try_hack_me(name: str = config.SUPER_SECRET_NAME):
3636
public_ip = public_ip_response.text
3737
name = name or config.SUPER_SECRET_NAME
3838
content = f"<h1>Hello, {name}!</h1><h2>Public IP: <code>{public_ip}</code></h2>"
39-
# FIXME: https://fastapi.tiangolo.com/advanced/custom-response/#return-a-response
39+
# https://fastapi.tiangolo.com/advanced/custom-response/#return-a-response
40+
# FIXME: return HTMLResponse(content)
4041
return Template(content).render()

tests/test_main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ def test_root(requests_mock):
3535
response.content.decode()
3636
== "<h1>Hello, Bob!</h1><h2>Public IP: <code>123.45.67.89</code></h2>"
3737
)
38+
# TODO
39+
# response = client.get("/?name={{7*6}}")
40+
# assert "42" not in response.content.decode()
41+
# assert "{{7*6}}" in response.content.decode()

0 commit comments

Comments
 (0)