Spaces:
Runtime error
Runtime error
yuanjie
commited on
Commit
·
dfe3c39
1
Parent(s):
23c6d6b
update
Browse files- AppZoo.py +4 -4
- pages/2_📚_PDF预览.py +12 -12
AppZoo.py
CHANGED
|
@@ -2,10 +2,10 @@ import streamlit as st
|
|
| 2 |
|
| 3 |
|
| 4 |
def run():
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
st.write("# Welcome to AppZoo! 👋")
|
| 11 |
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
def run():
|
| 5 |
+
st.set_page_config(
|
| 6 |
+
page_title="Hello",
|
| 7 |
+
page_icon="👋",
|
| 8 |
+
)
|
| 9 |
|
| 10 |
st.write("# Welcome to AppZoo! 👋")
|
| 11 |
|
pages/2_📚_PDF预览.py
CHANGED
|
@@ -3,21 +3,21 @@ from appzoo.streamlit_app import Page
|
|
| 3 |
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
-
|
| 7 |
-
https://zhuanlan.zhihu.com/p/518115802?utm_medium=social&utm_oi=1290068536690085888
|
| 8 |
-
"""
|
| 9 |
class MyPage(Page):
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def main(self):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# st.markdown(pdf_display, unsafe_allow_html=True)
|
| 21 |
|
| 22 |
|
| 23 |
if __name__ == '__main__':
|
|
|
|
| 3 |
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
+
|
|
|
|
|
|
|
| 7 |
class MyPage(Page):
|
| 8 |
+
"""
|
| 9 |
+
https://zhuanlan.zhihu.com/p/518115802?utm_medium=social&utm_oi=1290068536690085888
|
| 10 |
+
"""
|
| 11 |
|
| 12 |
def main(self):
|
| 13 |
+
with st.form("PDF"):
|
| 14 |
+
file = st.file_uploader("选择待上传的PDF文件", type=['pdf'])
|
| 15 |
+
|
| 16 |
+
if st.form_submit_button('开始预览', help='先上传文件!!!'):
|
| 17 |
+
if file is not None:
|
| 18 |
+
base64_pdf = base64.b64encode(file.read()).decode('utf-8')
|
| 19 |
+
pdf_display = f"""<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="800" type="application/pdf">"""
|
| 20 |
+
st.markdown(pdf_display, unsafe_allow_html=True)
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
if __name__ == '__main__':
|