Skip to content

Commit

Permalink
use whitenoise to serve static files
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-peters committed Mar 17, 2021
1 parent d6c564a commit a0d0c94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ markupsafe==1.1.1
# via jinja2
werkzeug==1.0.1
# via flask
whitenoise==5.2.0
# via strong-but-simple-passwords (setup.py)

# The following packages are considered to be unsafe in a requirements file:
# setuptools
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
version="0.1.0",
packages=find_packages(),
include_package_data=True,
install_requires=["flask", "gunicorn"],
install_requires=["flask", "whitenoise", "gunicorn"],
)
6 changes: 6 additions & 0 deletions strong_but_simple_passwords/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from flask import Flask
from whitenoise import WhiteNoise
from pathlib import Path
from .config import get_config_from_env_vars
from . import views

Expand All @@ -13,4 +15,8 @@ def create_app(config=None):

app.add_url_rule("/", "index", view_func=views.index, methods=("GET", "POST"))

# use whitenoise to serve static files
static_root = Path(__file__).parent / "static/"
app.wsgi_app = WhiteNoise(app.wsgi_app, root=static_root, prefix="static/")

return app

0 comments on commit a0d0c94

Please sign in to comment.