Spaces:
Running
Running
First Commit for test Hugging face platform
Browse files- streamlit_app.py +0 -27
streamlit_app.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import requests
|
3 |
-
|
4 |
-
# Streamlit 页面设置
|
5 |
-
st.title('AI Model API Interface')
|
6 |
-
st.write('输入文本,获取模型预测结果。')
|
7 |
-
|
8 |
-
# 用户输入
|
9 |
-
user_input = st.text_area('请输入文本:')
|
10 |
-
|
11 |
-
if st.button('提交'):
|
12 |
-
if user_input.strip():
|
13 |
-
with st.spinner('正在预测...'):
|
14 |
-
try:
|
15 |
-
response = requests.post(
|
16 |
-
'http://127.0.0.1:5000/predict',
|
17 |
-
json={'input': user_input}
|
18 |
-
)
|
19 |
-
if response.status_code == 200:
|
20 |
-
prediction = response.json()
|
21 |
-
st.success(f'预测结果: {prediction}')
|
22 |
-
else:
|
23 |
-
st.error(f'错误: {response.text}')
|
24 |
-
except Exception as e:
|
25 |
-
st.error(f'请求失败: {e}')
|
26 |
-
else:
|
27 |
-
st.warning('请输入文本!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|