Got gunicorn working. Problem with sqlite intiailization to fix.

This commit is contained in:
Matthew Raymer
2023-09-28 08:34:21 -04:00
parent 2322ab7c83
commit ebebd2fce2
3 changed files with 85 additions and 84 deletions
+1 -1
View File
@@ -38,4 +38,4 @@ COPY --from=builder /usr/local /usr/local
USER myuser
# Start gunicorn with the appropriate options
CMD ["gunicorn", "-b", "0.0.0.0:5000", "--workers=3", "app:app"]
CMD ["gunicorn", "-b", "0.0.0.0:3000", "--log-level=debug", "--workers=3", "app:create_app('default')"]
+4 -4
View File
@@ -6,10 +6,12 @@ from pywebpush import webpush, WebPushException
import json
import os
def create_app(config_name):
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///webpush.db'
db.init_app(app)
def generate_and_save_vapid_keys():
vapid = Vapid()
vapid.generate_keys()
@@ -21,11 +23,11 @@ def generate_and_save_vapid_keys():
db.session.commit()
@app.before_first_request
def initialize():
if not VAPIDKey.query.first():
generate_and_save_vapid_keys()
def send_push_notification(subscription_info, message, vapid_key):
try:
webpush(
@@ -90,6 +92,4 @@ def unsubscribe():
else:
return jsonify(success=False, error="Subscription not found"), 404
if __name__ == '__main__':
app.run(debug=True)
return app
+2 -1
View File
@@ -1,4 +1,5 @@
flask
flask>=2.0.0
flask_sqlalchemy
py_vapid
pywebpush
gunicorn