-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Flask Framework

Before we start creating our API, we need to create a database model for the resource that we wish to share. The API we are building will be used to create and retrieve comments using AJAX, so our model will contain all the fields that would be relevant for storing an unauthenticated user's comment on one of our entries.
For our purposes, the following fields should be sufficient:
name
, the name of the person making the comment
email
, the e-mail address of the person commenting, which we will use solely to display an image of them from Gravatar
URL
, the URL to the commenters blog
ip_address
, the IP address of the commenter
body
, the actual comment
status
, one of either Public
, Spam,
or Deleted
created_timestamp
, the timestamp with which the comment was created
entry_id
, the ID of blog entry the comment relates to
Lets begin coding by creating the Comment model definition in our app's models.py
module:
class Comment(db.Model): STATUS_PENDING_MODERATION = 0 ...
Change the font size
Change margin width
Change background colour