fixed Dockerfile - I only needed to expose 443, not sure what I was thinking mashing this web code with DB, anyway... also switched to using env var rather than hostname to pick up DEV/PROD, and now show that in base.html. Updated Dockerfile and requirements to prep for putting ldap/auth in, will need to copy some stuff from PA later. finally removed console debugs in book.html

This commit is contained in:
2022-06-19 16:15:51 +10:00
parent 6087bdab9e
commit 4725f006bc
6 changed files with 37 additions and 17 deletions

18
main.py
View File

@@ -7,20 +7,16 @@ from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerF
from flask_wtf import FlaskForm
from status import st, Status
import re
import socket
import os
####################################### Flask App globals #######################################
DEV_HOST="mara"
hostname = socket.gethostname()
print( "Running on: {}".format( hostname) )
app = Flask(__name__)
### what is this value? I gather I should chagne it?
# local DB conn string
if hostname == DEV_HOST:
DB_URL = 'postgresql+psycopg2://ddp:NWNlfa01@127.0.0.1:5432/library'
else:
if os.environ['FLASK_ENV'] == "production":
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@bookdb:5432/library'
else:
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@127.0.0.1:55432/library'
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
@@ -750,7 +746,7 @@ def main_page():
return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage())
if __name__ == "__main__":
if hostname == DEV_HOST:
app.run(host="0.0.0.0", debug=True)
else:
if os.environ['FLASK_ENV'] == "production":
app.run(ssl_context=('/etc/letsencrypt/live/book.depaoli.id.au/cert.pem', '/etc/letsencrypt/live/book.depaoli.id.au/privkey.pem'), host="0.0.0.0", debug=False)
else:
app.run(host="0.0.0.0", debug=True)