Issue
Is it ways to document my html template right from flask views like that?:
@app.route('/data_transcript', methods=['GET', 'POST'])
def data_transcript():
"""string for html template"""
# to do some stuff
return render_template('index.html', doc_string= """string for html template""")
index.html :
<html>
<body>
{{doc_string}}
</body>
</html>
Solution
You can access the doc string for a function in it's __doc__
attribute, so you can write:
@app.route('/data_transcript', methods=['GET', 'POST'])
def data_transcript():
"""string for html template"""
# to do some stuff
return render_template('index.html', doc_string=data_transcript.__doc__)
Answered By - larsks
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.