w

web-app

用 Streamlit + Tabulator.js 展示 DataFrame,支援欄位過濾、分頁、編輯,前端美觀又實用 🚀

0 0 0 1
1 import streamlit as st
2 import pandas as pd
3 import json
4 import streamlit.components.v1 as components
5
6 # 假設有一個 DataFrame
7 df = pd.DataFrame({
8 "訂單單別": ["A", "B", "C"],
9 "訂單單號": [101, 102, 103],
10 "客戶簡稱": ["客戶1", "客戶2", "客戶3"],

這是一個使用 Streamlit 構建的訂餐系統,包含訂購人選擇、餐廳菜單顯示、主餐及加點品項的選擇與數量輸入,並計算和顯示訂單詳情與總價。

0 0 0 1
1 from datetime import date
2
3 import streamlit as st
4
5 # 定義 Customer 類別
6 class Customer:
7 def __init__(self, name, email, preferences):
8 self.name = name
9 self.email = email
10 self.preferences = preferences

這段程式碼使用 streamlit_authenticator 建立一個簡單的登入系統,支持使用者驗證(帳號、密碼)和登出功能,並在側邊欄提供登出按鈕。密碼經過雜湊處理以增加安全性。

0 0 0 1
1 import streamlit as st # 匯入 streamlit 模組
2 import streamlit_authenticator as stauth # 匯入 streamlit_authenticator 模組
3
4 names = ["John", "Mary"] # 定義名字清單
5 usernames = ["john", "mary"] # 定義使用者名清單
6 passwords = ["1234", "5678"] # 定義密碼清單
7
8 hashed_passwords = stauth.Hasher(passwords).generate() # 使用 Hasher 類別對密碼進行雜湊處理
9
10 authenticator = stauth.Authenticate( # 建立一個 stauth.Authenticate 的實例 authenticator