Skip to content

mariobox/flask-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask-blog

A basic CMS built with Flask, Jinja and SQLite.

I created this app as part of my CS50x final projects.

The specs called for a rudimentary content management system where you can write blog posts, store them in a database and display them on an index page (newer posts first). It also needed to allow users to register and log in, and the ability for registered users to edit and delete posts.

The index page, while not logged in, looks like this:

The posts are stored in a SQLite database and displayed via a "SELECT * FROM posts ORDER BY id DESC" query in the "/" route.

The registration page shows you a form with several fields, indicating the conditions for each field to become valid:

The form validation function uses jQuery for several of the fields, so that we don't have to send a request to the server every time.

Once registered, you are redirected to a login page:

Once logged-in, you can edit and delete posts just by clicking the appropriate button:

You can write and edit posts in HTML to give them nice formatting.

Since the post content is written in a textarea of a form, you have to specifically include the "Safe" flag for the content to show HTML formatting (check the arcicle.html template).

If you want to see the blog in action, fork the repository to your own computer and perform the following commands from the command line in your project folder:

export FLASK_APP=application.py
flask run

This assumes you have Python, Flask and SQLite installed in your computer, as well as the following modules necessary to run application.py:

from cs50 import SQL
from flask_session import Session
from flask import Flask, render_template, redirect, request, session, jsonify
from datetime import datetime

About

A basic CMS built with Flask, Jinja and SQLite

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published