@@ -7,19 +7,37 @@ Let's create a simple blog app with the help of [Flask](https://flask.palletspro
77Let's create a directory for our blog project. After you have created your project directory, create virtual environment using the following commands:
88- Windows
99 ``` bash
10+ c:\> python -m venv c:\p ath\t o\m yenv
1011 ```
1112- Linux//MacOs
1213 ``` bash
14+ python3 -m venv /path/to/new/virtual/environment
1315 ```
14-
16+
17+ Activate the virtual environment:
18+ - Windows cmd
19+ ``` bash
20+ C:\> < venv> \S cripts\a ctivate.bat
21+ ```
22+
23+ - Windows powershell
24+ ``` powershell
25+ <venv>\Scripts\Activate.ps1
26+ ```
27+
28+ - Linux//MacOs
29+ ``` bash
30+ source < venv> /bin/activate
31+ ```
32+
1533Now let's use ` pip ` to install required modules and packages that we will be using in this project.
1634``` bash
1735pip install flask markdown
1836```
1937
2038## Creating the flask app
2139
22- First, create a new Flask app:
40+ First, create a new Flask app, by creating a file in root of the project directory called ` main.py ` :
2341
2442``` python
2543from flask import Flask, render_template
@@ -35,8 +53,6 @@ def home():
3553 return render_template(' index.html' )
3654```
3755
38- Create a directory called posts and add some Markdown files with blog post content.
39-
4056Define a route to handle requests for individual blog posts:
4157
4258``` python
@@ -94,4 +110,35 @@ def home():
94110 return render_template(' index.html' , posts = posts)
95111```
96112
97-
113+ ## Adding markdown posts
114+
115+ Now before running the app, let's add few posts.
116+ Create a directory called ` posts ` and add some Markdown files with blog post content.
117+ Let's add a ` hello.md ` :
118+
119+ ``` markdown
120+ # Hello
121+
122+ This is my first blog post
123+ ### Heading level 3
124+ #### Heading level 4
125+ ##### Heading level 5
126+ ###### Heading level 6
127+
128+ I just love ** bold text** .
129+
130+ ```
131+
132+ Now, let's run the app, type the following command:
133+
134+ ``` bash
135+ python main.py
136+ ```
137+
138+ Here is how it would look, I have 2 blog posts and have some gifs in my blog posts. Navigate to ` 127.0.0.0:5000 ` in a browser window:
139+
140+ ![ Home Page of our blog] ( /2023/images/day48-1.png )
141+
142+ If we click on the ` hello ` blog post:
143+
144+ ![ Hello blog post] ( /2023/images/day48-2.png )
0 commit comments