表情網站
https://getemoji.com/
官網:
https://streamlit.io/
文檔
https://docs.streamlit.io/develop/api-reference/chat/st.chat_message
安裝:
pip install streamlit
啟動
以下的python 文件指寫streamlit 程序的腳步。
1、先切換目錄到Python文件放置的目錄下
切換到d盤
命令 d:
切換到對應的文件夾
命令 cd D:\code\streamlit
2、在cmd中運行python 文件,啟動一個網頁。
streamlit run xx.py --server.port 8501
成果后顯示
3、在程序運行期間,需要保障命令行不關閉否則會出現連接不上的問題。Python文件是否關閉不產生影響。
4、通過subprocess 庫,將上述的三步寫成python文件。運行該文件后即可啟動頁面,并且該方式沒有命令行的黑框。
import subprocess# 假設'xx'是相對于當前腳本的目錄,且'app_chatlm.py'位于'xx'目錄下
directory = "D:\xx\code\streamlit"
app_script = "app_chatlm.py"# 構造一個shell命令序列
command_sequence = f"cd {directory} && streamlit run {app_script} --server.port 8501"# 使用shell=True來通過shell執行命令序列
subprocess.run(command_sequence, shell=True)
6、如果頁面不能自動彈出,需要手動點擊Local URL。
5、增加內容
修改py文件并保存后,刷新網頁即可。