Py.Cafe

gbrammer/

streamlit-on-pycafe

Streamlit on Py.cafe

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import streamlit as st
import numpy as np
import pandas as pd
from io import StringIO

print("\x1b[1;92mStreamlit script running...\x1b[0m")

st.title("streamlit on pycafe")

st.markdown(
    """
Py.cafe is a platform that allows you to create, run, edit, and share Python applications directly in your browser. There's
no need for any installation; it works with just a single click.
            
And now, you can use Streamlit on py.cafe! Streamlit is a popular Python library for creating web applications with simple
Python scripts. You can create interactive web applications with just a few lines of code.

"""
)

st.header("Example components")


st.subheader("Text input")
name = st.text_input("Your name?")
st.write("Hello,", name or "world", "!")


st.subheader("Slider")
value = st.slider("Value?")
st.write("The slider value is", value)


st.subheader("Chart sample")
chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
st.area_chart(chart_data)


st.subheader("DataFrame sample")
df = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
st.dataframe(df)  # Same as st.write(df)

dja = pd.read_csv(StringIO("""root,file,z_best,Mass,ha_eqw_with_limits,Thumb,Slit_Thumb,Spectrum_fnu,Spectrum_flam
rubies-egs61-v4,rubies-egs61-v4_prism-clear_4233_75646.spec.fits,4.9000187,10.873998434439217,24.333621346695423,"![thumb](https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=214.91554591%2C52.94901831)","![slit](https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=214.91554591%2C52.94901831&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw04233006001)", ![fnu](https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-egs61-v4/rubies-egs61-v4_prism-clear_4233_75646.fnu.png){height=100px}, <img src="https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-egs61-v4/rubies-egs61-v4_prism-clear_4233_75646.flam.png" height=200>
gds-barrufet-s67-v4,gds-barrufet-s67-v4_prism-clear_2198_8777.spec.fits,4.653013,10.676886339500623,8.261126684936823,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.10820397%2C-27.82518775"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.10820397%2C-27.82518775&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw02198003001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gds-barrufet-s67-v4/gds-barrufet-s67-v4_prism-clear_2198_8777.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gds-barrufet-s67-v4/gds-barrufet-s67-v4_prism-clear_2198_8777.flam.png"" height=200px>"
gds-barrufet-s67-v4,gds-barrufet-s67-v4_prism-clear_2198_8290.spec.fits,4.343858266666667,10.555604762470704,4.0581049349918725,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.08187859%2C-27.82879899"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.08187859%2C-27.82879899&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw02198003001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gds-barrufet-s67-v4/gds-barrufet-s67-v4_prism-clear_2198_8290.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gds-barrufet-s67-v4/gds-barrufet-s67-v4_prism-clear_2198_8290.flam.png"" height=200px>"
jades-gdn09-v4,jades-gdn09-v4_prism-clear_1181_72127.spec.fits,4.133680975,10.577063626736148,75.79743664465047,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2657184%2C62.1683933"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2657184%2C62.1683933&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01181009001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn09-v4/jades-gdn09-v4_prism-clear_1181_72127.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn09-v4/jades-gdn09-v4_prism-clear_1181_72127.flam.png"" height=200px>"
glazebrook-cos-obs1-v4,glazebrook-cos-obs1-v4_prism-clear_2565_10559.spec.fits,4.289708,10.551778374893852,3.8049630627883584,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=150.07143593%2C2.29117893"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=150.07143593%2C2.29117893&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw02565301001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-cos-obs1-v4/glazebrook-cos-obs1-v4_prism-clear_2565_10559.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-cos-obs1-v4/glazebrook-cos-obs1-v4_prism-clear_2565_10559.flam.png"" height=200px>"
jades-gds-wide-v4,jades-gds-wide-v4_prism-clear_1180_12619.spec.fits,3.6080465857142863,10.632365953875674,27.81629080375401,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.1969096%2C-27.7605277"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=53.1969096%2C-27.7605277&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01180029001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gds-wide-v4/jades-gds-wide-v4_prism-clear_1180_12619.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gds-wide-v4/jades-gds-wide-v4_prism-clear_1180_12619.flam.png"" height=200px>"
rubies-uds2-v4,rubies-uds2-v4_prism-clear_b28.spec.fits,4.362746250000001,10.880176042597437,5.617153390075587,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.2805153%2C-5.21721404"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.2805153%2C-5.21721404&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw04233001002"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-uds2-v4/rubies-uds2-v4_prism-clear_b28.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-uds2-v4/rubies-uds2-v4_prism-clear_b28.flam.png"" height=200px>"
rubies-uds2-v4,rubies-uds2-v4_prism-clear_4233_b28.spec.fits,4.362746250000001,10.880066167019105,5.592120044597749,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.2805153%2C-5.21721404"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.2805153%2C-5.21721404&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw04233001002"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-uds2-v4/rubies-uds2-v4_prism-clear_4233_b28.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/rubies-uds2-v4/rubies-uds2-v4_prism-clear_4233_b28.flam.png"" height=200px>"
glazebrook-cos-obs3-v4,glazebrook-cos-obs3-v4_prism-clear_2565_20115.spec.fits,3.7129283,11.223065060803133,2.6172271180121762,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=150.06146711%2C2.37868632"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=150.06146711%2C2.37868632&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw02565007001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-cos-obs3-v4/glazebrook-cos-obs3-v4_prism-clear_2565_20115.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-cos-obs3-v4/glazebrook-cos-obs3-v4_prism-clear_2565_20115.flam.png"" height=200px>"
gto-wide-egs1-v4,gto-wide-egs1-v4_prism-clear_1213_4358.spec.fits,4.28981825,10.691810773473456,21.9825271128086,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=215.03907944%2C53.0027735"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=215.03907944%2C53.0027735&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01213002001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gto-wide-egs1-v4/gto-wide-egs1-v4_prism-clear_1213_4358.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/gto-wide-egs1-v4/gto-wide-egs1-v4_prism-clear_1213_4358.flam.png"" height=200px>"
jades-gdn09-v4,jades-gdn09-v4_prism-clear_1181_80660.spec.fits,4.399828175,10.217724584150755,25.751004827027923,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2754487%2C62.2141353"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2754487%2C62.2141353&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01181009001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn09-v4/jades-gdn09-v4_prism-clear_1181_80660.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn09-v4/jades-gdn09-v4_prism-clear_1181_80660.flam.png"" height=200px>"
glazebrook-v4,glazebrook-v4_prism-clear_2565_10459.spec.fits,3.9868546593184164,10.682939422960546,4.653039435829561,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.34034528%2C-5.24130895"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=34.34034528%2C-5.24130895&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw02565100001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-v4/glazebrook-v4_prism-clear_2565_10459.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/glazebrook-v4/glazebrook-v4_prism-clear_2565_10459.flam.png"" height=200px>"
jades-gdn198-v4,jades-gdn198-v4_prism-clear_1181_76320.spec.fits,3.2385862249999997,10.305974807670594,5.321300992291246,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2214567%2C62.1924022"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2214567%2C62.1924022&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01181198001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn198-v4/jades-gdn198-v4_prism-clear_1181_76320.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn198-v4/jades-gdn198-v4_prism-clear_1181_76320.flam.png"" height=200px>"
macs1149-v4,macs1149-v4_prism-clear_1208_5103925.spec.fits,3.69631,10.823495667095123,6.45298957404942,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=177.38919232%2C22.36724586"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=177.38919232%2C22.36724586&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01208049001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/macs1149-v4/macs1149-v4_prism-clear_1208_5103925.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/macs1149-v4/macs1149-v4_prism-clear_1208_5103925.flam.png"" height=200px>"
jades-gdn-v4,jades-gdn-v4_prism-clear_1181_76320.spec.fits,3.2385862249999997,10.331598508835654,4.69577553725491,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2214567%2C62.1924022"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=189.2214567%2C62.1924022&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw01181098001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn-v4/jades-gdn-v4_prism-clear_1181_76320.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/jades-gdn-v4/jades-gdn-v4_prism-clear_1181_76320.flam.png"" height=200px>"
capers-egs49-v4,capers-egs49-v4_prism-clear_6368_7806.spec.fits,3.4438524,10.285034381997477,33.252768398903065,"<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=2.0&asinh=True&filters=f115w-clear%2Cf277w-clear%2Cf444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=214.8790898%2C52.8880604"" height=200px>","<img src=""https://grizli-cutout.herokuapp.com/thumb?size=1.5&scl=4.0&invert=True&filters=f444w-clear&rgb_scl=1.5%2C0.74%2C1.3&pl=2&coord=214.8790898%2C52.8880604&nirspec=True&dpi_scale=6&nrs_lw=0.5&nrs_alpha=0.8&metafile=jw06368049001"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/capers-egs49-v4/capers-egs49-v4_prism-clear_6368_7806.fnu.png"" height=200px>","<img src=""https://s3.amazonaws.com/msaexp-nirspec/extractions/capers-egs49-v4/capers-egs49-v4_prism-clear_6368_7806.flam.png"" height=200px>"
""")
)

print("dja table")
st.subheader("DJA data")
st.markdown(dja.to_markdown())  # Same as st.write(df)

st.subheader("Camera and image")
if st.checkbox("Show camera"):
    picture = st.camera_input("Take a picture")

    if picture:
        st.image(picture)

st.markdown(
    """
### Useful links:
            
* [Streamlit official website](https://streamlit.io/)
* [Streamlit documentation](https://docs.streamlit.io/)

### Alternatives
            
Also take a look at [stlite](https://edit.share.stlite.net/), a similar platform that allows you to create, run, edit, and share Python applications directly in your browser.
            
Py.cafe runs an unmodified version of streamlit, compared to stlite which has some modifications to make it work in the browser.

### Community

 * [Py.cafe Discord](https://discord.gg/RpwWnFV3Dv)
 * [Streamlit community forum](https://discuss.streamlit.io/)
"""
)