Skip to content

Commit

Permalink
Add dummy index.html file
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Heffer-Shef committed Jul 24, 2024
1 parent 56fe84a commit 4af7d19
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
13 changes: 13 additions & 0 deletions backend/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 11 additions & 4 deletions backend/btviewer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions backend/btviewer/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<title>btviewer development 🐝</title>
</head>
<body>
<h1>Hello, world! 🐝</h1>
<p>
You are running this app in development mode.
</p>
<p>
This HTML file will be overwritten with the front-end code.
</p>
</body>
</html>

0 comments on commit 4af7d19

Please sign in to comment.