Flask Development Server
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.
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()