https://github.com/openanalytics/shinyproxy-flask-demo
Running Flask apps inside ShinyProxy
https://github.com/openanalytics/shinyproxy-flask-demo
containers docker flask kubernetes python shinyproxy
Last synced: 17 days ago
JSON representation
Running Flask apps inside ShinyProxy
- Host: GitHub
- URL: https://github.com/openanalytics/shinyproxy-flask-demo
- Owner: openanalytics
- Created: 2021-07-14T09:20:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T13:50:21.000Z (over 1 year ago)
- Last Synced: 2024-08-03T22:20:23.079Z (over 1 year ago)
- Topics: containers, docker, flask, kubernetes, python, shinyproxy
- Language: HTML
- Homepage: https://www.shinyproxy.io
- Size: 32.2 KB
- Stars: 7
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - openanalytics/shinyproxy-flask-demo - Running Flask apps inside ShinyProxy (HTML)
README
# Running Flask apps inside ShinyProxy
In order to run Flask apps using ShinyProxy you have to consider two things:
- use a WSGI web server to run the Flask app (e.g., gunicorn, uWSGI). This means
you cannot use the built-in server provided by Flask. Note that the developers
of Flask advice to not use their built-in server for production usages. The
[Dockerfile](Dockerfile) in this repository illustrates how you can setup
gunicorn for a very simple Flask application.
- ensure to use the `url_for` helper when referencing other pages and static
files. The HTML files in the [app/templates](app/templates) directory show the
proper usage of the `url_for` helper. For example:
```html
About
```
## Building the Docker image
To pull the image made in this repository from Docker Hub, use
```bash
sudo docker pull openanalytics/shinyproxy-flask-demo
```
The relevant Docker Hub repository can be found at .
To build the image from the Dockerfile, navigate into the root directory of this repository and run
```bash
sudo docker build -t openanalytics/shinyproxy-flask-demo .
```
## ShinyProxy Configuration
**Note:** ShinyProxy 2.6.0 or later is required for running Flask apps.
Create a ShinyProxy configuration file (see [application.yml](application.yml)
for a complete file), containing:
```yaml
proxy:
specs:
- id: flask-demo
container-image: openanalytics/shinyproxy-flask-demo
port: 8080
container-env:
SCRIPT_NAME: "#{proxy.getRuntimeValue('SHINYPROXY_PUBLIC_PATH').replaceFirst('/$','')}"
target-path: "#{proxy.getRuntimeValue('SHINYPROXY_PUBLIC_PATH')}"
```
Note that the `SCRIPT_NAME` environment variable may not end with `/`, therefore
we have to strip it from the variable.
## References
-
-
-
- [Running FastAPI app in ShinyProxy](https://github.com/openanalytics/shinyproxy-flask-demo)
**(c) Copyright Open Analytics NV, 2021-2024.**