top of page

Flask Automation Home

  • Jun 6, 2019
  • 2 min read

We learn about automation home, which mean a house that we can control the electronic appliances inside by using an application. What we are doing is the small scale of that thing. We create a web page that will control the LED, show the humidity and temperature, and tell whether currently it was dark or not. The main components in this work are RGBLED, humidity and temperature sensor, and the light sensor. We use Flask to handle all our website. The main domain name for a flask website is http://localhost:5000/ but if we make it to be able to open by other appliances such as our phone then the domain will become the host IP address instead. We use the function app.route to set the location of our website. And the look of that particular website will depend on the value that the function below it return. For example, we said @app.route("/homepage") with a homepage() function below it, meaning that if we add the word homepage after the http://localhost:5000/ to be http://localhost:5000/homepage the flask will automatically run the function homepage() below it. And usually the function will return a HTML value; the the flask will read that HTML and make it appear on our screen. We also need other function to keep updating our website. For our homepage, we use ajax to keep updating the information collected and sent by the sensor. The ajax will open the website location and retrieve the returned value of the function below and then replace the information retrieved to the HTML tag with the same class name as what we assigned. Usually, the value returned from a function that work with ajax won't be a whole HTML file but more like a connected "string" that form a HTML tag. This will prevent the ajax to need to refresh our site too much and decrease the memory usage. For example, the daynight() function will return an image tag that specific the image that will appear depending on the value that the light sensor read. Other web-page our website work the same ways but just use other components instead.

ESLOs:

- Strategic Learners

- Innovative Thinker

- Leader of the future


Comments


Recent Posts

© 2023 by  Designs by Thomas Rider. Proudly created with Wix.com

bottom of page