web_blog
web_blog copied to clipboard
Simple web-based blog to introduce Flask, HTML, CSS, Bootstrap, and Jinja2.
Web blog
Original course code | Code updated to Flask 2.0
This is a simple web-based blog that doesn't do much but introduces Flask, HTML, CSS, Bootstrap, Jinja2, and other concepts such as endpoints and APIs.
The blog requires MongoDB to be running without authentication enabled.
Once this is running, execute the app with flask run
and navigate to the endpoint (default: http://127.0.0.1:5000/
).
The available endpoints are:
-
/
-
/login
-
/register
-
/blogs
-
/blogs/new
-
/posts/<string:blog_id>
-
/posts/new/<string:blog_id>
How to use this code
- Create a new virtual environment:
python -m venv .venv
- Activate the virtual environment:
In powershell:
.\.venv\Scripts\activate
In bash
source .venv/Scripts/activate
In CMD
.venv\Scripts\activate
In Mac OS / Linux:
source .venv/bin/activate
-
Verify that the file
.flaskenv
is in the top directory and that it contains the environment variableFLASK_APP=src.app
. -
Run the app
flask run