• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    HTML
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A guide for deploying Shinylive Python application into Github Pages

This repo provides an example of a Shinylive app. Shinylive enables to create a serverless Shiny applications with Python. Leveraging WebAssembly, it can run the Shiny app on the web browser without a server on the backend.

Example

Inspired by Prof. Richard McElreath's explanation about why normal distribution is normal in Statistical Rethinking chapter 3, created the following app:

The app is available here and with code on the shinylive editor

Why normal distributions are normal

Chapter 3 illustrates how to generate a normal distribution using the soccer field experiment:

  • Place a bunch of people at the center line of a soccer field
  • Each person flips a coin and moves one step to the right or left according to the outcome (head or tail)
  • Repeat this process multiple times

After a couple of iterations, you will notice the distribution of the people's distances across the field will become Gaussian or normal (e.g., bell-curved shape).

The app above simulates this experience by setting the sample size (i.e., number of people) and number of iterations. Where on each iteration, we draw a random number between -1 and 1 (can choose between float integer steps with the Step Type drop-down). The plot above shows the cumulative sum of each experiment across each step of the experience. You can notice how the distribution becomes more Gaussian as the number of steps increases.

Deploy shinylive app on Github Pages

As shinylive apps are serverless, you can deploy your app into Github Pages. First, create your app with the following step:

shiny create myapp

This will create the app file - app.py with the default shinylive example under the myapp folder:

.
└── myapp
    └── app.py

Next, update your app and build the site with the shiny static command:

shiny static myapp docs

We mapped the app folder - myapp to the website folder docs (Github Pages required the website name to set as docs). This will add the following folders:

.
├── docs
│   ├── edit
│   └── shinylive
│       ├── jquery.terminal
│       │   ├── bin
│       │   ├── css
│       │   └── js
│       ├── pyodide
│       │   └── fonts
│       ├── pyright
│       └── shiny_static
│           └── edit
└── myapp

You can test locally your app with the following command:

python3 -m http.server --directory docs 8008

and open on your browser using http://localhost:8008/.

Note: Any time you change your app, you will have to run shiny static myapp docs to update the docs folder.

Once you finilize your app, commit and push your changes and open your repo on Github and go to the Settings tab and select the Pages option (blue boxes):

Next, select under Build and deployment select the Deploy from branch option (green box) and under the branch option your branch you want to deploy from and the docs folder (purple box).

The site should be ready few minutes after with the following URL:

YOUR_GITHUB_USER_PROFILE.github.io/YOUR_REPO_NAME

The URL for the example above available here: https://ramikrispin.github.io/shinylive/

More Repositories

1

coronavirus

The coronavirus dataset
HTML
499
star
2

TSstudio

Tools for time series analysis and forecasting
R
421
star
3

deploy-flex-actions

Deploying flexdashboard on Github Pages with Docker and Github Actions
HTML
185
star
4

awesome-ds-setting

A tutorial for setting a new machine with core data science tools
181
star
5

vscode-python

Setting Python Development Environment with VScode and Docker
145
star
6

atsaf

Applied Time Series Analysis and Forecasting
R
130
star
7

coronavirus_dashboard

The Coronavirus Dashboard
R
105
star
8

USelectricity

Forecast the US demand for electricity
R
96
star
9

italy_dash

A summary dashboard of the covid19 cases in Italy
Dockerfile
75
star
10

MLstudio

The ML Studio Package
R
70
star
11

covid19Italy

Italy covid19 data
R
46
star
12

coronavirus-csv

CSV format for the coronavirus R package dataset
R
46
star
13

30DayChartChallenge

Code for 30DayChartChallenge
R
34
star
14

UKgrid

The UK National Grid historical demand for electricity
R
28
star
15

30DayMapChallenge

30 Day Map Challenge 2022
R
27
star
16

R-Ladies-Tunis-Docker-Workshop

R-Ladies Tunis Docker for R users workshop
Dockerfile
24
star
17

uselectricity-etl

Example for ETL process with R, Docker, and Github Actions (WIP...).
R
24
star
18

USgrid

The hourly demand and supply of electricity in the US
R
23
star
19

Introduction-to-JavaScript

Introduction to JavaScript - math operations, variables, functions, objects, etc.
TeX
16
star
20

uswildfire

US Wildfire Dashboard
Shell
15
star
21

gis-dataviz-workshop

Materials for R-Ladies Abuja geospatial visualization workshop
HTML
14
star
22

sfo

Monthly air passengers and landings at San Francisco International Airport (SFO)
R
13
star
23

Time-Series-Workshop

Bay Area useR Group Time Series Workshop
HTML
13
star
24

covid19sf

R package for tracking Covid19 cases in San Francisco
R
12
star
25

RamiKrispin

My README profile
9
star
26

Shiny-App

A shiny interface for ML models, data visualization etc.
R
8
star
27

USgas

Tracking US monthly consumption of natural gas
R
7
star
28

ai-dev-2024-ml-workshop

Materials for the AI Dev 2024 "Deploy and Monitor ML Pipelines with Open Source and Free Applications" workshop
Shell
7
star
29

halloween-time-series-workshop

Bay Area useR Group Halloween Time Series Workshop
HTML
7
star
30

shinylive-r

A guide for deploying Shinylive R application into Github Pages
6
star
31

EIAapi

Supporting tools for the Applied Time Series Analysis and Forecasting book
R
6
star
32

flexdashboard_example

An example for deployment of flexdashboard
5
star
33

Julia-tutorials

Julia's learning materials
Julia
2
star
34

forecastML

Time series forecasting with linear regression and machine learning methods
R
2
star
35

learningR

Learning R
2
star
36

visualization_final

2
star
37

rstudio-conf-ggplot2-workshop

Setting Docker environment for the Graphic Design with ggplot2 workshop at RStudio conf 2022
R
2
star
38

covid19-US

Dashboard to track the covid19 pandemic in the US
1
star
39

covid19wiki

Collections of covid19 tables sourced from Wiki pages
R
1
star
40

covid19county

R
1
star
41

math_expressions

Example of using mathematical expressions in a README file
1
star
42

docker

My Docker files
Shell
1
star
43

RamiKrispin.github.io

My blog
HTML
1
star
44

piecewise-regression

An Introduction to Piecewise Regression with Time Series
R
1
star
45

linkedin-dashboard

Example of LinkedIn Profile Engagement Dashboard
R
1
star
46

TStrain

Approaches and methods for training forecasting models
HTML
1
star
47

shiny-express-poc

Running Shiny Express App Inside a Container
JavaScript
1
star
48

rstudio-conf-2020-geospatial

This repo contains the materials from the geospatial training.
1
star
49

ts-cluster-analysis-r

Materials for the the Analyzing Time Series at Scale with Cluster Analysis in R Workshop
R
1
star