Spaces:
Runtime error
Runtime error
File size: 1,376 Bytes
34d7a98 15374ec 34d7a98 15374ec |
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 |
import streamlit as st
import inspect
import textwrap
class Page(object):
def __init__(self, app_title="# App Title",
app_info="> App Info",
sidebar_title="## Sidebar Title",
page_title="Page Title",
page_icon='🔥',
menu_items=None,
show_code=False
):
st.set_page_config(
page_title=page_title,
page_icon=page_icon,
initial_sidebar_state='auto',
menu_items=menu_items
)
if app_title: st.markdown(app_title)
if app_info: st.markdown(app_info)
if sidebar_title: st.sidebar.markdown(sidebar_title)
if sidebar_title and show_code: self.show_code(self.main)
def main(self):
raise NotImplementedError('Method not implemented!')
def show_code(self, demo):
"""Showing the code of the demo."""
_ = st.sidebar.checkbox("Show code", False)
if _:
# Showing the code of the demo.
st.markdown("---")
st.markdown("## Main Code")
sourcelines, _ = inspect.getsourcelines(demo)
st.code(textwrap.dedent("".join(sourcelines[1:])))
st.markdown("---")
class SPage(Page):
def main(self):
st.markdown(f"{st}=={st.__version__}")
SPage().main()
|