Spaces:
Runtime error
Runtime error
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() | |