Skip to content

Commit

Permalink
put .css files into separate directory and disable flask static file …
Browse files Browse the repository at this point in the history
…serving
  • Loading branch information
chr-peters committed Mar 17, 2021
1 parent a0d0c94 commit c97efca
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion strong_but_simple_passwords/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


def create_app(config=None):
app = Flask(__name__)
# don't use a static_folder since we will use whitenoise to serve the static files
app = Flask(__name__, static_folder=None)

if config is None:
config = get_config_from_env_vars()
Expand Down
6 changes: 3 additions & 3 deletions strong_but_simple_passwords/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap" rel="stylesheet">

<link rel="stylesheet" href="{{ url_for('static', filename='normalize.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<link rel="stylesheet" href="/static/css/normalize.css">
<link rel="stylesheet" href="/static/css/styles.css">

<title>How to generate a strong but simple password</title>
</head>

<body>
<header>
<a id="github" href="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/cxan96/strong-but-simple-passwords">
<img src="{{ url_for('static', filename='img/GitHub-Mark-64px.png') }}">
<img src="/static/img/GitHub-Mark-64px.png">
</a>
</header>
<main>
Expand Down
4 changes: 2 additions & 2 deletions tests/test_static_files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def test_css_http_ok(app, client):
response = client.get("/static/styles.css")
response = client.get("/static/css/styles.css")
assert response.status_code == 200

response = client.get("/static/normalize.css")
response = client.get("/static/css/normalize.css")
assert response.status_code == 200


Expand Down

0 comments on commit c97efca

Please sign in to comment.