From 686cc5dacadbed843743f76a1cec4a7e50c882bf Mon Sep 17 00:00:00 2001 From: Cam Date: Sun, 10 Jan 2021 11:57:12 +1100 Subject: [PATCH] added base app.route, and a templates folder with a base.html --- main.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 508f4ff..9d0add5 100644 --- a/main.py +++ b/main.py @@ -10,17 +10,14 @@ import re import socket ####################################### Flask App globals ####################################### -DEV_HOST="mara" +PROD_HOST="pa_web" hostname = socket.gethostname() print( "Running on: {}".format( hostname) ) app = Flask(__name__) ### what is this value? I gather I should change it? -# local DB conn string -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' +# connection string: pguseraccount, pgpasswd, mara as the host, db port is 55432, dbname +DB_URL = 'postgresql+psycopg2://pa:for_now_pa@mara.ddp.net:55432/pa' app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -29,8 +26,12 @@ db = SQLAlchemy(app) ma = Marshmallow(app) Bootstrap(app) +@app.route("/", methods=["GET"]) +def main_page(): + return render_template("base.html") + if __name__ == "__main__": - if hostname == DEV_HOST: - app.run(host="0.0.0.0", debug=True) - else: + if hostname == PROD_HOST: 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)