Flask is a micro web framework written in Python. It is easy to learn and ideal for small to medium sized web applications. To create a blog using Flask, you will first need to install it.
I Assume you have :
Basic knowledge of Python programming language.
Check if Python is installed in your system
Open terminal and run below command
python --version
Creating environment
It is recommended to use virtual environment for dependencies and other packages.
Create a virtual environment
python -m venv env
Activate virtual environment
source env/bin/activate
Installing Flask
pip install Flask
This command install latest version of django in your system
Verify Installation
flask --version
Once you have Flask installed, you can start building your app by creating a new Flask application and setting up the required routes and templates. Here are the steps to create a basic Flask app:
- Create a new directory for your Flask project and navigate into it.
- Create a file called
app.py
and import Flask. - Create an instance of the Flask class and define a route for the home page.
- Create templates for the home page and layout.
- Run the application and view it in your web browser.
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
if __name__ == '__main__':
app.run(debug=True)
You can then create templates for the home page and layout, and run the application to view it in your web browser. This is just a basic example, and you can build upon it to add more features and functionality to your app.