1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Rep Power

    Continuously Updating a webpage

    I have a web page and a server that uses CGI scripts written in python. When I button is hit on the page the CGI scripts runs and sends commands through the serial port to one of my microcontrollers. This works ok to just send a button, string, or receive a response to that button press.

    But I want to be able to continuously update the webpage with the status of my MCU (microcontroller). Like if a switch is pressed or the temperature goes up in my circuit. O a continuous update of a motors speed.

    I tried the html code:
    <meta http-equiv="refresh" content=".05">

    But it is terrible for high speed (.05 sec). I cant even push a button it is refreshing so fast.

    I have read about socket programming in python to keep the connection from the client and server going to seamlessly update content. I need to update the content that is generated by my servers COM port.

    What can I use to do this? Is there good examples that you know of?

    Thank you.
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    A Land Down Under
    Rep Power
    I'd suggest using AJAX to do this. Set up your page to display some details and use an AJAX function to get the data from your server on a set interval. For something like this, you can always set your function up to call itself on success so basically a never-ending loop of fetching new results. It will also save a lot of bandwidth as you'd only need to send back some basic JSON data, and not the entire pages HTML code.

IMN logo majestic logo threadwatch logo seochat tools logo