Skip to content

Add a configurable route to serve the contents of a directory

Adam Coldrick requested to merge sotk/browser/static-files into master

Before raising this MR, consider whether the following are required, and complete if so:

  • Unit tests
  • Metrics
  • Documentation update(s)

If not required, please explain in brief why not.

Description

This MR adds a --static-path option to bgd browser-backend which takes the name of a directory to serve as static files at /. This allows the backend process to also serve the bgd-browser client, to simplify the number of pieces needed for deployment in some cases.

This static file serving is implemented with a custom GET handler rather than aiohttp's built in static file serving (which isn't really meant for production anyway). This is because simple static file serving doesn't work when using Vue Router in history mode (as we do). The custom handler returns the contents of index.html in the configured directory when the URL is simply / or the path part of the URL doesn't match a static file in the directory.

Edited by Adam Coldrick

Merge request reports