Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import subprocess
|
|
|
3 |
|
4 |
#=======================================================================================================================#
|
5 |
|
@@ -27,7 +28,6 @@ with st.sidebar:
|
|
27 |
"Upload file", type=["pdf"],
|
28 |
help="Only PDF files are supported",
|
29 |
on_change=clear_submit)
|
30 |
-
|
31 |
# Add a button
|
32 |
if uploaded_file:
|
33 |
st.markdown('---')
|
@@ -40,15 +40,23 @@ with st.sidebar:
|
|
40 |
|
41 |
if uploaded_file:
|
42 |
|
43 |
-
|
44 |
-
#
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Create output file
|
47 |
output_file = f'{uploaded_file.name}'.replace('.pdf', '.mmd')
|
48 |
output_path = f'./files/'
|
49 |
|
50 |
# mmd path
|
51 |
-
mmd_path =
|
|
|
52 |
|
53 |
#with open(input_path, 'wb') as f:
|
54 |
#f.write(uploaded_file.getbuffer())
|
@@ -68,6 +76,7 @@ if uploaded_file:
|
|
68 |
# move mmd to the session state
|
69 |
st.session_state["mmd"] = mmd
|
70 |
|
|
|
71 |
try:
|
72 |
st.write(st.session_state["mmd"])
|
73 |
|
@@ -81,7 +90,4 @@ if uploaded_file:
|
|
81 |
mime='text/markdown')
|
82 |
|
83 |
except:
|
84 |
-
pass
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import subprocess
|
3 |
+
import os
|
4 |
|
5 |
#=======================================================================================================================#
|
6 |
|
|
|
28 |
"Upload file", type=["pdf"],
|
29 |
help="Only PDF files are supported",
|
30 |
on_change=clear_submit)
|
|
|
31 |
# Add a button
|
32 |
if uploaded_file:
|
33 |
st.markdown('---')
|
|
|
40 |
|
41 |
if uploaded_file:
|
42 |
|
43 |
+
|
44 |
+
# create files folder
|
45 |
+
if not os.path.exists('files'):
|
46 |
+
os.makedirs('files')
|
47 |
+
|
48 |
+
# Create a temporary folder in streamlit
|
49 |
+
# input_path = uploaded_file.read()
|
50 |
+
input_path = f'./files/{uploaded_file.name}'
|
51 |
+
# input_path = os.path.join('files', uploaded_file.name)
|
52 |
+
|
53 |
# Create output file
|
54 |
output_file = f'{uploaded_file.name}'.replace('.pdf', '.mmd')
|
55 |
output_path = f'./files/'
|
56 |
|
57 |
# mmd path
|
58 |
+
mmd_path = os.path.join('files', output_file)
|
59 |
+
# mmd_path = f'./files/{output_file}'
|
60 |
|
61 |
#with open(input_path, 'wb') as f:
|
62 |
#f.write(uploaded_file.getbuffer())
|
|
|
76 |
# move mmd to the session state
|
77 |
st.session_state["mmd"] = mmd
|
78 |
|
79 |
+
|
80 |
try:
|
81 |
st.write(st.session_state["mmd"])
|
82 |
|
|
|
90 |
mime='text/markdown')
|
91 |
|
92 |
except:
|
93 |
+
pass
|
|
|
|
|
|