-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
52 additions
and
1,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Streamlit demo | ||
============== | ||
|
||
Upload to Jamsocket: | ||
|
||
```bash | ||
npx jamsocket@latest service create my-streamlit-demo | ||
npx jamsocket@latest service push my-streamlit-demo -f ./Dockerfile | ||
``` | ||
|
||
Spawn an instance of the service: | ||
|
||
```bash | ||
npx jamsocket@latest spawn my-streamlit-demo | ||
``` | ||
|
||
Open the "ready" URL in your browser. | ||
|
||
Then, upload a streamlit app: | ||
|
||
```bash | ||
curl -X POST --data-binary @app.py https://<result of spawn>/_frag/upload/app.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
import streamlit as st | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
def mandelbrot(c, max_iter): | ||
z = c | ||
for n in range(max_iter): | ||
if abs(z) > 2: | ||
return n | ||
z = z*z + c | ||
return max_iter | ||
|
||
def draw_mandelbrot(xmin,xmax,ymin,ymax,width,height,max_iter): | ||
r1 = np.linspace(xmin, xmax, width) | ||
r2 = np.linspace(ymin, ymax, height) | ||
return (r1,r2,np.array([[mandelbrot(complex(r, i),max_iter) for r in r1] for i in r2])) | ||
|
||
def main(): | ||
st.title('Mandelbrot Explorer') | ||
|
||
# Set up the parameters | ||
xmin = st.sidebar.slider('xmin', -2.0, 0.5, -2.0) | ||
xmax = st.sidebar.slider('xmax', -2.0, 0.5, 0.5) | ||
ymin = st.sidebar.slider('ymin', -1.5, 1.5, -1.5) | ||
ymax = st.sidebar.slider('ymax', -1.5, 1.5, 1.5) | ||
width = st.sidebar.slider('width', 100, 1000, 500) | ||
height = st.sidebar.slider('height', 100, 1000, 500) | ||
max_iter = st.sidebar.slider('max_iter', 1, 1000, 256) | ||
|
||
# Draw the mandelbrot set | ||
d = draw_mandelbrot(xmin,xmax,ymin,ymax,width,height,max_iter) | ||
st.pyplot(plt.imshow(d[2], extent=(xmin, xmax, ymin, ymax))) | ||
st.title('Hello World!') | ||
|
||
if __name__ == "__main__": | ||
main() | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.