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
from fasthtml.common import * | |
leaflet_css = Link(rel="stylesheet", href="https://unpkg.com/[email protected]/dist/leaflet.css", type='text/css') | |
leaflet_js = Script(src="https://unpkg.com/[email protected]/dist/leaflet.js") | |
app, rt = fast_app(hdrs=(leaflet_css, leaflet_js), live=True) | |
@dataclass | |
class Coords: | |
latitude:str |
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
""" | |
File-system based router inspired from Next.js, where folders are used to define routes. | |
Each folder with a page.py maps to a URL segment. | |
The title for the page in the navigation menu is the argument of the first `st.title` call. | |
Example Directory Structure: | |
├── app | |
│ ├── page.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
import streamlit as st | |
##### Initialize Session State | |
if "counter" not in st.session_state: | |
st.session_state.counter = 0 | |
if "timer" not in st.session_state: | |
st.session_state.timer = 0 | |
##### Build Logic into Fragments |
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
import streamlit as st | |
from vega_datasets import data | |
st.title("Vega Datasets Explorer") | |
all_datasets = data.list_datasets() | |
selected_dataset = st.selectbox("Select data:", all_datasets) | |
df = getattr(data, selected_dataset.replace("-", "_"))() | |
st.dataframe(df, use_container_width=True) |
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
import streamlit as st | |
from transformers import pipeline | |
from huggingface_hub import HfApi | |
from huggingface_hub import ModelFilter | |
st.set_page_config(page_title="Huggingface Course", page_icon="🤗") | |
@st.cache_resource | |
def load_hf_model(model: str): |
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
import streamlit as st | |
from streamlit.delta_generator import DeltaGenerator | |
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto | |
from streamlit.string_util import clean_text | |
def markdown_but_yelling(body, unsafe_allow_html=False): | |
body = f"# {body.upper()}!!!!" | |
markdown_proto = MarkdownProto() | |
markdown_proto.body = clean_text(body) |
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
{ | |
"editor.fontSize": 16, // 16 on demo, 14 otherwise | |
"editor.lineHeight": 22, // 22 on demo, 18 otherwise | |
"window.zoomLevel": 1.5, // 1.5 on demo, 1.2 otherwise | |
"editor.formatOnSave": false, | |
"editor.formatOnPaste": false, | |
"editor.lineNumbers": "off", | |
"editor.quickSuggestionsDelay": 3000, | |
"editor.quickSuggestions": { | |
"other": false, |
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
""" | |
pip install beautifulsoup4 ghapi requests streamlit | |
Add [github] > key value of your Github API Token in .streamlit/secrets.toml | |
streamlit run streamlit_app.py | |
""" | |
from typing import Tuple | |
import pandas as pd | |
import requests | |
import streamlit as st |
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
import base64 | |
import streamlit as st | |
import streamlit.components.v1 as components | |
import plotly.express as px | |
df = px.data.iris() | |
@st.experimental_memo | |
def get_img_as_base64(file): |
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
"""https://www.freakyjolly.com/multipage-canvas-pdf-using-jspdf/""" | |
import requests | |
import plotly.express as px | |
import streamlit as st | |
import streamlit.components.v1 as components | |
@st.experimental_memo | |
def load_unpkg(src: str) -> str: | |
return requests.get(src).text |
NewerOlder