added base app.route, and a templates folder with a base.html

This commit is contained in:
2021-01-10 11:57:12 +11:00
parent ea98e0fd13
commit 686cc5daca

19
main.py
View File

@@ -10,17 +10,14 @@ import re
import socket import socket
####################################### Flask App globals ####################################### ####################################### Flask App globals #######################################
DEV_HOST="mara" PROD_HOST="pa_web"
hostname = socket.gethostname() hostname = socket.gethostname()
print( "Running on: {}".format( hostname) ) print( "Running on: {}".format( hostname) )
app = Flask(__name__) app = Flask(__name__)
### what is this value? I gather I should change it? ### what is this value? I gather I should change it?
# local DB conn string # connection string: pguseraccount, pgpasswd, mara as the host, db port is 55432, dbname
if hostname == DEV_HOST: DB_URL = 'postgresql+psycopg2://pa:for_now_pa@mara.ddp.net:55432/pa'
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_DATABASE_URI'] = DB_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
@@ -29,8 +26,12 @@ db = SQLAlchemy(app)
ma = Marshmallow(app) ma = Marshmallow(app)
Bootstrap(app) Bootstrap(app)
@app.route("/", methods=["GET"])
def main_page():
return render_template("base.html")
if __name__ == "__main__": if __name__ == "__main__":
if hostname == DEV_HOST: if hostname == PROD_HOST:
app.run(host="0.0.0.0", debug=True)
else:
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) 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)