Flask is a micro-framework in Python for developing web applications. Flask supports jinja2 template engine. We will use Flask framework for developing our mini (sometimes major) IoT based Applications in Raspberry PI. Because of it’s REST like request handling system it become very easy to develop APIs and/or web clients/server like applications. Flask is very easy to use. Easy to get start with and have complete documentation with lot’s of examples available over internet.

Hello world! in Flask Python

Flask could be easily installed via PIP package manager from command line with as simple as this

 pip install Flask 

A simple Hello World Application with Flask framework could be very simple with few lines of code like this

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"
if __name__ == "__main__":
    app.run()Code language: JavaScript (javascript)

You could also run this application using Flask Command as described in Documentation

FLASK_APP=hello.py flask run

Now if you are running this in Raspberry Pi like in our case then enter IP-Address of your Raspberry PI in browser with http://192.168.43.102:5000/ address and"Hello World!" will appear in browser.

References

By Abdul Rehman

My name is Abdul Rehman and I love to do Reasearch in Embedded Systems, Artificial Intelligence, Computer Vision and Engineering related fields. With 10+ years of experience in Research and Development field in Embedded systems I touched lot of technologies including Web development, and Mobile Application development. Now with the help of Social Presence, I like to share my knowledge and to document everything I learned and still learning.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.