If you are the type who cannot wait to start coding, the source code will be provided at the end of the article. You can grab it and take a look first.
To start, create a folder and name it HelloWorld. You can name it whatever you want to, but for simplicity, I will name it HelloWorld.
Change directory to the newly created folder and create 'app.py' file. This will be our python script in which we will write the server to run our app on localhost.
from flask import Flask, render_template
app = Flask(__name__)
if __name__ == '__main__':
Our app.py will only contain this much. Now, as you can see on line 5, we are are return an index.html file as our template. Flask automatically calls this index.html file from a folder called templates. So let us create our templates folder.
Create a folder and name it templates. Make sure to get the name of the folder correct[templates] or else Flask will not find any html file.
Create an index.html file in the templates folder and add any html template you want to. For this tutorial we will focus on creating a simple Hello World heading. Below is the markup text for our index.html file.
Run python3 app.py from the root project and you should be able to see Hello World @ localhost:5000.
Note that this tutorials assumes you already have Flask installed globally on your system. If you don't, simply run pip3 install flask and you should be good to go!
Click here to get source code.