The backend server Flask was created fully in Python. It is a framework made up of Python modules and packages. With its characteristics, it is a lightweight Flask application that speeds up the development of backend apps. We will learn how to execute a Flask application in this tutorial.
Run Flask application Syntax
We can run the Flask application using the below command.
flask –app <hello> run
flask run
python <app_name>.py
File Structure
Here, we are using the following folder and file.

Run a Flask Application
In this example, we have an application called helloworld.py below is the basic code for Flask.
Python3
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
if __name__ == '__main__':
app.run()
|
Output:
Using flask –app <app_name> run

Using flask run

Using the python app_name.py


Run the app in the debugger
We will use the below command to run the flask application with debug mode as on. When debug mode is turned on, It allows developers to locate any possible error and as well the location of the error, by logging a traceback of the error.
if __name__ == ‘__main__’:
app.run(debug = True)

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.
Last Updated :
20 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...