SHA256
27 lines
671 B
Python
27 lines
671 B
Python
"""Dev/Prod entry point. Runs the Flask app, over TLS when certs exist."""
|
|
|
|
import os
|
|
import ssl
|
|
|
|
from backend.app import app
|
|
from backend import storage
|
|
|
|
|
|
def main():
|
|
storage.init_db()
|
|
|
|
cert = os.path.join("certs", "cert.pem")
|
|
key = os.path.join("certs", "key.pem")
|
|
|
|
if os.path.exists(cert) and os.path.exists(key):
|
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
|
context.load_cert_chain(cert, key)
|
|
app.run(host="127.0.0.1", port=8443, ssl_context=context)
|
|
else:
|
|
print("WARNING: no certs/ found, running WITHOUT TLS (dev only!).")
|
|
app.run(host="127.0.0.1", port=5000)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|