TinyMCE and Flask
Posted on
by Kevin FoongIn this post I will run through process of setting up the TinyMCE editor with Flask. TinyMCE is a great WYSIWYG editor and suitable for things like blog posts. It also enables you to upload images directly into your text.
Follow the instructions below to set up TinyMCE as a local download.
- In Flask I create your forms as per normal using Flask-WTF. Note that the
post
field is defined as a TextAreaField. Later we will be using the TinyMCE editor to replace this field.
class PostForm(FlaskForm):
heading = StringField('Title', validators=[InputRequired(), Length(max=100)])
post = TextAreaField('Write something')
tags = StringField('Tags')
submit = SubmitField('Submit')
- Now download TinyMCE (see https://www.tiny.cloud/docs/general-configuration-guide/advanced-install/#sdkinstall)
and unzip the contents into a web accessible location. I downloaded mine into a folder named "tinymce" under the static folder. - Create a route which will look something like this.
Read more ...