docker deploy

This commit is contained in:
leo
2023-12-31 16:35:43 +08:00
parent ef5b45eb21
commit bf2a285716
2 changed files with 18 additions and 3 deletions

14
main.py
View File

@@ -1,6 +1,7 @@
import os
import streamlit as st
from loguru import logger
from app.core import settings
@@ -13,13 +14,20 @@ def new_file():
new_file_name = st.session_state.new_file
if not new_file_name.endswith('.py'):
new_file_name = f'{new_file_name}.py'
with open(os.path.join(settings.BASE_DIR, 'pages', new_file_name), 'w') as f:
f.write('''
logger.debug(f"create new file: {new_file_name}")
content = '''
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import streamlit as st
{add_content}
st.write('Hello World!')
''')
'''
with open(os.path.join(settings.BASE_DIR, 'pages', new_file_name), 'w') as f:
content = content.format(add_content=f"""st.markdown("# {st.session_state.new_file}")""").strip()
st.write(f"create new file: {new_file_name}, write: ")
st.code(content, language='python')
f.write(content)
with st.sidebar: