What is Flask?
Flask is a micro-web-framework based on python. Micro-framework is normally a framework with little to no external dependencies on libraries. Though being a micro-framework Flask is as effective as any other web framework because of its wide range of available python libraries like SQLAlchemy, Flask-Migrate, etc. In this article, we will be discussing what a development server is and why is it used.
What is a development server?
A development server is a server that is used in the development, testing of programs, websites, software, or applications by developers. It provides a runtime environment as well as all hardware/software utilities that are required for program debugging and development.
You can use a development server to check whether your web application is working as expected or not. In flask when debug settings are set to true, you can also use the development server to debug your application.
In this article, we will create a single-page flask-based web application and explain the different methods by which you can run your development server.
Creating Flask Web Application -
Module Installation: To install flask using pip(package installer for python) run the following command:
pip install flask
Example: Following is the code for a simple flask application that has a single page and we will use the development server to check whether the page is served in the application as expected.
Filename: app.py python from flask import Flask, render_template app = Flask(__name__) # Debug setting set to true app.debug = True @app.route('/') def index(): return "Greetings from GeeksforGeeks" if __name__ == '__main__': app.run()
Starting development server: Starting a development server in the flask using the following command.
python <name>.py
Here <name> is the name of the file where the instance of the flask app has been created and the app.run() function exists. By convention, this file is mostly named app, thus the command will be shown below.
python app.py
The development server will open up on http://127.0.0.1:5000/ and you will see the following output on your browser screen.
Greetings from GeeksforGeeks
Lazy Loading Or Eager Loading - When using the development server it will continue to run even if you introduce syntax errors or other initialization errors into the code. Accessing the site with the errors will show the interactive debugger for the error, rather than crashing the server. This feature is called lazy-loading. In simpler words in lazy-loading, the server does not crash even if something goes wrong in your application rather an informative debugger page loads up.
To activate lazy loading you can modify the command as follows:
python app.py --lazy-loading
Now, in eager loading, if an error is present in the application code or some probable section of the application, then rather than loading the interactive debugger the development server fails with a detailed traceback of the error.
To activate eager loading you can modify the command as follows:
python app.py --eager-loading
Reference: https://flask.palletsprojects.com/en/2.0.x/
Similar Reads
Fullstack Web Development Fullstack web development refers to the practice of building web applications that encompass both frontend and backend components. A full-stack developer is proficient in frontend technologies, such as HTML, CSS, and JavaScript, as well as backend technologies, such as server-side programming langua
5 min read
Introduction to Web development using Flask Flask is a lightweight and flexible web framework for Python. It's designed to make getting started with web development quick and easy, while still being powerful enough to build complex web applications. It is an API of Python that allows us to build web applications. It was developed by Armin Ron
10 min read
Python for Web Development To excel in web development with Python, you need to master key concepts, frameworks, tools, and deployment strategies. This comprehensive roadmap provides a step-by-step approach to mastering Python web development. It covers everything from the fundamentals to advanced concepts like API design, se
4 min read
Full Stack Development Tools [2025 Updated] Full stack development involves working on both the front-end (client side) and back-end (server side) of a web application. It requires a comprehensive set of tools to handle all aspects of web application, from the user interface to the server-side logic and data storage (database). We will go thr
10 min read
Flask - Role Based Access Control Role-Based Access Control (RBAC) is a security mechanism that restricts user access based on their roles within an application. Instead of assigning permissions to individual users, RBAC groups users into roles and each role has specific permissions.For example, in a Flask app, we might have roles l
9 min read