docker deploy
This commit is contained in:
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
build_self:
|
||||
build: .
|
||||
ports:
|
||||
- "5001:80"
|
||||
14
main.py
14
main.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user