Member-only story
Web application using Flask and deploy it to the cloud
It makes the process of designing a web application simpler. Flask lets us focus on what the users are requesting and what sort of response to give back.
How Does a Flask App Work?
The code lets us run a basic web application that we can serve, as if it were a website.
from flask import Flask app = Flask(__name__) @app.route("/") def home(): return "Hello, World!" if __name__ == "__main__": app.run(debug=True)
This piece of code is stored in our main.py.
Line 1: Here we are importing the Flask module and creating a Flask web server from the Flask module.
Line 3: __name__ means this current file. In this case, it will be main.py. This current file will represent my web application.
We are creating an instance of the Flask class and calling it app. Here we are creating a new web application.
Line 5: It represents the default page. For example, if I go to a website such as “google.com/” with nothing after the slash. Then this will be the default page of Google.
Line 9: When you run your Python script, Python assigns the name “__main__” to the script when executed.