Reader small image

You're reading from  Developing IoT Projects with ESP32 - Second Edition

Product typeBook
Published inNov 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803237688
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Vedat Ozan Oner
Vedat Ozan Oner
author image
Vedat Ozan Oner

Vedat Ozan Oner is an IoT product developer and software architect, with an excellent blend of technical knowledge and experience. During his career, he has contributed to several IoT projects in different roles, which allowed him to discover all key aspects of developing successful IoT products in highly competitive markets. Vedat has a bachelor's degree in METU/computer engineering and holds several industry-recognized credentials and qualifications, including PMP®, ITIL®, and AWS Certified Developer. Vedat started his limited company, Mevoo Ltd, in London in 2018 to provide consultancy services to his clients as well as develop his own IoT products. He still lives in London with his family.
Read more about Vedat Ozan Oner

Right arrow

Consuming RESTful services

In this example, our sensor will read its configuration from a RESTful server by connecting it as a client and publishing its state on the same server. As a server, we will run a simple Flask application in a virtual Python environment. Let’s prepare the server in steps:

  1. Copy the ch6/rest_client_ex/server directory from the GitHub repository and switch to this directory. Install the Python requirements in a virtual environment:
    $ python --version
    Python 3.6.8
    $ pyenv virtualenv 3.6.8 apptest
    $ pyenv local apptest
    (apptest) $ pip install -r requirements.txt
    
  2. Set the Flask application:
    (apptest) $ export FLASK_APP=./rest_server.py
    
  3. Start the server. The -h 0.0.0.0 option makes Flask serve on all network interfaces of the machine:
    (apptest) $ flask run -h 0.0.0.0
    * Serving Flask app './rest_server.py' (lazy loading)
    <logs removed>
    * Running on http://10.8.0.2:5000/ (Press CTRL...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Developing IoT Projects with ESP32 - Second Edition
Published in: Nov 2023Publisher: PacktISBN-13: 9781803237688

Author (1)

author image
Vedat Ozan Oner

Vedat Ozan Oner is an IoT product developer and software architect, with an excellent blend of technical knowledge and experience. During his career, he has contributed to several IoT projects in different roles, which allowed him to discover all key aspects of developing successful IoT products in highly competitive markets. Vedat has a bachelor's degree in METU/computer engineering and holds several industry-recognized credentials and qualifications, including PMP®, ITIL®, and AWS Certified Developer. Vedat started his limited company, Mevoo Ltd, in London in 2018 to provide consultancy services to his clients as well as develop his own IoT products. He still lives in London with his family.
Read more about Vedat Ozan Oner