Posted on 2020-05-13T09:42:16Z by Kevin Foong
Slugs are great for SEO and humans alike. For example, "/post_detail/vue-spa-and-flask-together" looks much better than "/post_detail/8".
In Python it is very easy to create slugs from the title of your blog post. Just use the excellent python-slugify library. The command is simple.
slugify("Vue Spa and Flask Together")
This will give you the slug "vue-spa-and-flask-together"
Now in order to use the slug you will need to store it in your database. As you will be using the slug to query the database instead of the post id, you will also need to ensure that the slug is unique before saving to your database.
For the full source code of how this can be done view my Github page.
Tags:
flask
python
SEO
Posted on 2019-11-18T09:42:21Z by Kevin Foong
This is the second part of my earlier Flask / TinyMCE tutorial. See the first part here.
In this blog post I will outline the steps I used to save a thumbnail version of any image I upload to my post. Here I used the very useful Pillow (Python Imaging Library) library.
TinyMCE has a great image uploader feature where you can simply drag and drop images to directly upload into your post. I have summarised some of the main implementation points below:
Read more ...
Tags:
tinymce
flask
python
Posted on 2019-11-18T08:49:23Z by Kevin Foong
Using Python to analyse a dataset on Premier League soccer matches around the metrics of "possession" and "matches won", reveals some interesting findings. This is a previous assignment I did for my Udacity Nanodegree in Data Analysis.
In season 2015/2016 Leicester City won the league at starting odds of 5000-1. Their possession stats (number of matches where they had more possession than the opposition) put them 3rd from bottom, but then we can deduce that perhaps they were also a lethal counter-attacking side.

Read more ...
Tags:
python
data
Posted on 2019-04-30T04:33:47Z by Kevin Foong
In 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 ...
Tags:
tinymce
flask
python