Spaces:
Runtime error
Runtime error
File size: 946 Bytes
ee83c82 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from meutils.pipe import *
from appzoo.streamlit_app import Page
import streamlit as st
"""
https://zhuanlan.zhihu.com/p/518115802?utm_medium=social&utm_oi=1290068536690085888
"""
class MyPage(Page):
def main(self):
with st.form("PDF"):
file = st.file_uploader("选择待上传的PDF文件", type=['pdf'])
if st.form_submit_button('开始预览', help='先上传文件!!!'):
if file is not None:
base64_pdf = base64.b64encode(file.read()).decode('utf-8')
pdf_display = f"""<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="800" type="application/pdf">"""
st.markdown(pdf_display, unsafe_allow_html=True)
if __name__ == '__main__':
app_title = "# PDF应用"
app_info = "PDF预览"
MyPage(
app_title=app_title,
app_info=app_info,
sidebar_title=None,
).main()
|