Creating web apps is possibly one of the coolest things you could do in your lifetime. ;)
The reasons are obvious.
You can create something meaningful, everyone can use.
Follow me to get more information about the ServerMonitor in the near future.
Let's get started!
Flask is a lightweight Python web framework based on Werkzeug and Jinja2.
Lightweight means, Flask only has the most basic features to create your web application on your own.
Everything other like admin panels, for example, have to be built from scratch, unlike in Django.
For starting out in web development with Python, this makes a lot of sense.
You don't have to learn a lot of framework stuff before you can build a web app.
Make a folder where your Flask project should be located.
You can do this in CMD on Windows.
Then, open your created folder with:
Installing flask via PIP is quite easy.
pip install Flask
...to install the Flask module.
After installing Flask, we have to make a Python file.
I will call it 'main.py'
This file will contain all of the basic code for Flask to run.
from flask import Flask app = Flask(__name__) @app.route("/") def hello_www(): return "Hello World Wide Web!"
First of all, we import our installed Flask module from Flask with:
from flask import Flask
Then, we define the variable 'app' and assign "Flask(_ name _)" to it:
app = Flask(__name__)
After that, we can create our first route with:
To make it work, we need some return value, that will be displayed on our web page.
For that, we type:
def hello_www(): return "Hello World Wide Web!"
Last but not least, we will return a String with "Hello World Wide Web!".
After we have created and saved our code, we want to see the result.
For that, you first need to define your Python file for Flask in this way:
If this is done, you can start your web app with:
You have created your first web app.
If you want to dive deeper into the Flask-World, visit http://flask.pocoo.org/.