diff --git a/backend/CONTRIBUTING.md b/backend/CONTRIBUTING.md index d690e5d..3f79962 100644 --- a/backend/CONTRIBUTING.md +++ b/backend/CONTRIBUTING.md @@ -47,6 +47,19 @@ flask --app backend.btviewer.app --debug run To run the frontend user interface in development mode, see the [frontend contribution guide](../frontend/CONTRIBUTING.md). +## Deployment + +The Python package is built and published by a GitHub Actions workflow. + +To test the installation of the package in a separate environment, you can install it directly from GitHub using the [VCS support](https://pip.pypa.io/en/stable/topics/vcs-support/) feature of `pip install`. For example: + +```bash +branch="my_name" +pip install git+https://github.com/SheffieldMLtracking/btviewer@$branch#subdirectory=backend +``` + + + ## Further reading - Flask [Project Layout](https://flask.palletsprojects.com/en/2.3.x/tutorial/layout/) and [tutorial example](https://github.com/pallets/flask/tree/3.0.2/examples/tutorial) \ No newline at end of file diff --git a/backend/btviewer/__main__.py b/backend/btviewer/__main__.py index 2a06ec6..caed989 100644 --- a/backend/btviewer/__main__.py +++ b/backend/btviewer/__main__.py @@ -40,9 +40,18 @@ def get_args() -> argparse.Namespace: return parser.parse_args() +def configure_logging(log_level): + # https://flask.palletsprojects.com/en/2.3.x/logging/ + # https://docs.pylonsproject.org/projects/waitress/en/stable/logging.html + logging.basicConfig(level=log_level) + + for name in {'waitress', 'werkzeug'}: + logging.getLogger(name).setLevel(log_level) + + def main(): args = get_args() - logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) + configure_logging(logging.DEBUG if args.verbose else logging.INFO) # Create WSGI app app = btviewer.app_factory.create_app(root_directory=args.root_directory) @@ -55,11 +64,9 @@ def main(): # Open frontend in web browser static_uri = uri + '/static/index.html' + logging.info('Front end %s', static_uri) webbrowser.open(static_uri) - print('flask where') - print(flask.url_for('static', filename='index.html')) - # Run web server # https://docs.pylonsproject.org/projects/waitress/en/latest/arguments.html waitress.serve(app, host=args.host, port=args.port, threads=args.threads) diff --git a/backend/btviewer/static/index.html b/backend/btviewer/static/index.html new file mode 100644 index 0000000..0266a60 --- /dev/null +++ b/backend/btviewer/static/index.html @@ -0,0 +1,15 @@ + + + + btviewer development 🐝 + + +

Hello, world! 🐝

+

+ You are running this app in development mode. +

+

+ This HTML file will be overwritten with the front-end code. +

+ +