Skip to content

Commit

Permalink
feat: serve 404 page locally (#160)
Browse files Browse the repository at this point in the history
Resolves #159

Signed-off-by: Mike Fiedler <[email protected]>
  • Loading branch information
miketheman authored Mar 28, 2024
1 parent 5756f29 commit d645a31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions inspector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def versions(project_name):
resp = requests.get(f"https://pypi.org/pypi/{project_name}/json")
pypi_project_url = f"https://pypi.org/project/{project_name}"

# Self-host 404 page to mitigate iframe embeds
if resp.status_code == 404:
return render_template("404.html")
if resp.status_code != 200:
return redirect(pypi_project_url, 307)

Expand Down
5 changes: 5 additions & 0 deletions inspector/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends 'base.html' %}

{% block body %}
<h1>NOT FOUND</h1>
{% endblock %}

0 comments on commit d645a31

Please sign in to comment.