From 0b1c8f5e7d873e7c822d8d5261e2be090bd6174d Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Fri, 31 Dec 2021 23:28:11 -0800 Subject: [PATCH] switch from app_server to `flask run` for local development app_server doesn't emit app logging messages from gunicorn workers, and it was nontrivial to add. also app_server seems largely abandoned, and flask run is well supported. --- README.md | 4 ++-- app.py | 4 +++- requirements.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2389a46..33c50ff 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,15 @@ Now, run the tests to check that everything is set up ok: ```shell gcloud beta emulators datastore start --no-store-on-disk --consistency=1.0 --host-port=localhost:8089 < /dev/null >& /dev/null & python3 -m unittest discover -kill %1 ``` Finally, run this in the repo root directory to start the web app locally: ```shell -dev_appserver.py --log_level debug --enable_host_checking false --support_datastore_emulator --datastore_emulator_port=8089 --application=bridgy-federated app.yaml +env GAE_ENV=localdev flask run -p 8080 ``` + If you send a pull request, please include (or update) a test for the new functionality! If you hit an error during setup, check out the [oauth-dropins Troubleshooting/FAQ section](https://github.com/snarfed/oauth-dropins#troubleshootingfaq). For searchability, here are a handful of error messages that [have solutions there](https://github.com/snarfed/oauth-dropins#troubleshootingfaq): diff --git a/app.py b/app.py index ac160dc..2793a96 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ import logging from flask import Flask from flask_caching import Cache +import flask_gae_static from oauth_dropins.webutil import ( appengine_info, appengine_config, @@ -13,7 +14,7 @@ from oauth_dropins.webutil import ( import common -app = Flask('bridgy-fed') +app = Flask(__name__) app.template_folder = './templates' app.config.from_mapping( ENV='development' if appengine_info.DEBUG else 'PRODUCTION', @@ -24,6 +25,7 @@ app.config.from_mapping( app.url_map.converters['regex'] = flask_util.RegexConverter app.after_request(flask_util.default_modern_headers) app.register_error_handler(Exception, flask_util.handle_exception) +flask_gae_static.init_app(app) # don't redirect API requests with blank path elements app.url_map.redirect_defaults = True diff --git a/requirements.txt b/requirements.txt index 40d0b90..23dd660 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,10 @@ git+https://github.com/snarfed/django-salmon.git#egg=django_salmon git+https://github.com/snarfed/httpsig.git@HTTPSignatureAuth-sign-header#egg=httpsig git+https://github.com/snarfed/oauth-dropins.git#egg=oauth_dropins git+https://github.com/snarfed/granary.git#egg=granary -app-server~=0.7.0; python_version>="3.8" feedparser~=6.0.8 flask~=2.0.2 flask-caching~=1.10.1 +flask-gae-static google-cloud-logging~=2.7.0 gunicorn~=20.1 mf2util~=0.5.1