Skip to content

Commit

Permalink
added configuration to load static files
Browse files Browse the repository at this point in the history
  • Loading branch information
kcrane3576 committed Jun 14, 2022
1 parent 4d797ad commit 6723bc4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .env.dev-sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ DATABASE=postgres

# SQLAlchemy
# db is a specific reference to the service in the docker-compose.yml file
DATABASE_URL=postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<SQL_HOST>:5432/<POSTGRES_DB>
DATABASE_URL=postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<SQL_HOST>:5432/<POSTGRES_DB>
APP_FOLDER=/usr/src/app
3 changes: 2 additions & 1 deletion .env.prod-sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ DATABASE=postgres

# SQLAlchemy
# db is a specific reference to the service in the docker-compose.yml file
DATABASE_URL=postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<SQL_HOST>:5432/<POSTGRES_DB>
DATABASE_URL=postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<SQL_HOST>:5432/<POSTGRES_DB>
APP_FOLDER=/usr/src/app
7 changes: 6 additions & 1 deletion services/web/project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, jsonify
from flask import Flask, jsonify, send_from_directory
from flask_sqlalchemy import SQLAlchemy


Expand All @@ -23,3 +23,8 @@ def __init__(self, email):
@app.route("/")
def hello_world():
return jsonify(hello="world")


@app.route("/static/<path:filename>")
def staticfiles(filename):
return send_from_directory(app.config["STATIC_FOLDER"], filename)
1 change: 1 addition & 0 deletions services/web/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ class Config(object):
# Otherwise, if it is not set, it will use: sqlite://
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", "sqlite://")
SQLALCHEMY_TRACK_MODIFICATIONS = False
STATIC_FOLDER = f"{os.getenv('APP_FOLDER')}/project/static"
1 change: 1 addition & 0 deletions services/web/project/static/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello

0 comments on commit 6723bc4

Please sign in to comment.