- Home
- >
- Mobile apps development
- >
- What is Flask? How To Create The Flask App?
Flask – a micro web framework written in Python programming language. It is classified as a micro-framework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, as well as other components where pre-existing third-party libraries provide some common functions. Moreover, it supports extensions that can add application features as well as implemented in it. Extensions exist for object-relational, form validation, upload handling as well as various open authentication technologies and several common frameworks related tools. The extension updated far more regularly than the core Flask program.

Flask is a web framework which provides you with tools, libraries, and technologies. That allows building a web application as well as this web application can be some web pages, a blog, a wiki or go as big as a web-based calendar application or for a commercial website.
Flask is part of the categories called the micro-framework. Micro-framework is generally a framework with external libraries. It also has pros and cons. Pros are that the framework is light even there is a little dependency to update and watch for security bugs whereas cons are sometimes you will have to do work by yourself as well as it increases yourself the list of dependencies by adding plugins which are quite annoying sometimes.
Key Summary
This InApps.net article, published in 2022 and authored by Phu Nguyen, introduces Flask, a Python-based micro web framework, and provides a guide to creating a basic Flask application. Written with a technical, instructional tone, it aligns with InApps Technology’s mission to cover software development trends, offering practical insights for developers.
Key Points:
- Context: Flask is a lightweight, flexible web framework in Python, ideal for building web applications ranging from simple pages to complex commercial sites, without built-in database or form validation layers.
- Core Insight: As a micro-framework, Flask relies on external libraries and extensions for additional functionality, enabling developers to create tailored web applications with minimal dependencies.
- Key Features:
- Flask Overview: A micro-framework that supports extensions for features like object-relational mapping, form validation, and authentication, updated more frequently than the core Flask program.
- Features: Supports configuration management, self-hosting with Gunicorn, static file serving with Nginx, Docker containerization, PostgreSQL database setup, and task queues for long-running tasks.
- Creating a Flask App:
- Set up a project structure with static and templates directories.
- Create a basic hello_flask.py file to initialize the Flask app and define routes (e.g., / for an index page).
- Use HTML templates (e.g., index.html) for rendering dynamic content.
- Add dynamic routes (e.g., /hello/<name>) to handle URL arguments and personalize responses.
- Pros and Cons: Lightweight with minimal dependencies (pro) but requires manual plugin integration, increasing dependency management (con).
- Outcome: Flask enables rapid development of scalable web applications with flexibility for customization, supported by InApps’ expertise in delivering robust software solutions.
This article reflects InApps.net’s focus on innovative software development, providing an inclusive, practical guide to building Flask applications.
Features of Flask application:
- Configuration management. An application has a lifecycle with specific stages—at the very least, it would be development, testing, as well as deployment.
- Self-hosting Flask application with Gunicorn.
- Serving static files request with Nginx.
- An app inside Docker containers on a dedicated Linux server.
- Configuring and deploying a PostgreSQL database for the application.
- Set-up a task queue to handle long-running tasks.
Above there is the basic knowledge about the Flask application, now let’s come to the second thing that how to create the Flask program? As the flask is written in a python programming language as well as classified into micro-framework.
Create a flask program:
Let’s start by creating an application code that which help you to make the flask application.
- First, create a structure.
mkdir -p hello_flask/{templates,static}
- As you see below, the basic structure of your application in Flask.
$ tree hello_flask/
hello_flask/
|-- static
`-- templates
- To create the application file.
cd hello_flask
vim hello_flask.py
- Put following code like given below to operate the flask.
import flask
# Create the application.
APP = flask.Flask(__name__)
@APP.route('/')
def index():
""" Displays the index page accessible at '/'
"""
return flask.render_template('index.html')
if __name__ == '__main__':
APP.debug=True
APP.run()
- Her to learn how to use HTML in flask to build an application as well as create the template index.html.
vim templates/index.html
- Following codes by using HTML.
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8" />
<title>Hello world!</title>
<link type="text/css" rel="stylesheet"
href="https://codersera.com/blog/what-is-flask-how-to-create-the-flask-app/{{ url_for("static',
filename="hello.css")}}" />
</head>
<body>
It works!
</body>
</html>
python hello_flask.py
USING ARGUMENTS IN YOUR FLASK APPLICATION.
In this step we learn that how to use the page according to URL.
- Here , add following entry as given in the code below.
@APP.route('/hello/<name>/')
def hello(name):
""" Displays the page greats who ever comes to visit it.
"""
return flask.render_template('hello.html', name=name)
- As well as, create the template in HTML.
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8" />
<title>Hello</title>
<link type="text/css" rel="stylesheet"
href="https://codersera.com/blog/what-is-flask-how-to-create-the-flask-app/{{ url_for("static',
filename="hello.css")}}" />
</head>
<body>
Hello {{name}}
</body>
</html>
- Run the Flask application
python hello_flask.py
Source: InApps.net
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.