TODO-24 (in docker) DONE

This commit is contained in:
2021-01-08 12:09:22 +11:00
parent e4606cdbeb
commit bed04f88f9
2 changed files with 15 additions and 8 deletions

16
main.py
View File

@@ -7,15 +7,20 @@ from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerF
from flask_wtf import FlaskForm
from status import st, Status
import re
import socket
####################################### 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
DB_URL = 'postgresql+psycopg2://ddp:NWNlfa01@127.0.0.1:5432/library'
# using temp.docker DB conn string
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@172.18.0.20:5432/library'
if hostname == DEV_HOST:
DB_URL = 'postgresql+psycopg2://ddp:NWNlfa01@127.0.0.1:5432/library'
else:
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@bookdb:5432/library'
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
@@ -644,4 +649,7 @@ def main_page():
return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage())
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
if hostname == DEV_HOST:
app.run(host="0.0.0.0", debug=True)
else:
app.run(host="0.0.0.0", debug=False)