main.py
文件代码:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash(__name__)
textarea = dcc.Textarea(value="",id="textrea",style={"width":"100%","height":"8rem"})
markdown = dcc.Markdown(children="",id="markdown")
app.layout = html.Div([
markdown,
html.H1("输入markdown格式内容:"),
html.Hr(),
textarea
])
@app.callback(
Output("markdown","children"),
[Input("textrea","value")]
)
def update(value):
return value
app.run_server(debug=True)
创建一个style.css
文件来设置网页样式:
body{
background-color: #ffdeae;
}
运行代码,浏览器打开http://127.0.0.1:8050/
,显示效果如下所示:
在输入框中输入markdown语法内容,显示效果如下所示: