@@ -0,0 +1,2365 @@
+#  This is a Python web server that handles requests to switch the Grove LED on/off, buzz the buzzer and show a message on the LCD screen.%0A#  Based on code from http://mattrichardson.com/Raspberry-Pi-Flask/%0Afrom flask import Flask, render_template%0Afrom grovepi import *%0Afrom grove_rgb_lcd import *%0Aimport datetime%0Aimport time%0A%0Aapp = Flask(__name__)%0A%0A# Connect the Grove LED to digital port D4%0Aled = 4%0ApinMode(led, %22OUTPUT%22)%0A%0A# Connect the Grove Buzzer to digital port D8%0A# SIG,NC,VCC,GND%0Abuzzer = 8%0ApinMode(buzzer, %22OUTPUT%22)%0A%0A# http://.../led_on will switch on the LED%0A@app.route(%22/led_on%22)%0Adef led_on():%0A    try:%0A        digitalWrite(led, 1)     # Send HIGH to switch on LED%0A        response = %22LED is now on%22%0A    except:%0A        response = %22There was an error switching on the LED%22%0A%0A    return response%0A%0A# http://.../led_off will switch off the LED%0A@app.route(%22/led_off%22)%0Adef led_off():%0A    try:%0A        digitalWrite(led, 0)     # Send LOW to switch off LED%0A        response = %22LED is now off%22%0A    except:%0A        response = %22There was an error switching off the LED%22%0A%0A    return response%0A%0A# http://.../buzz will buzz the buzzer%0A@app.route(%22/buzz%22)%0Adef buzz():%0A    try:%0A        # Buzz for 1 second%0A        digitalWrite(buzzer, 1)%0A        time.sleep(1)%0A%0A        # Stop buzzing after 1 second%0A        digitalWrite(buzzer, 0)%0A        response = %22Luppy has been buzzed%22%0A    except:%0A        response = %22There was an error buzzing Luppy%22%0A%0A    return response%0A%0A# http://.../lcd/msg will show msg on the LCD screen%0A@app.route(%22/lcd/%3Cmsg%3E%22)%0Adef lcd(msg):%0A    try:%0A        # Show the message%0A        setText(msg)%0A        # Set the background to yellow%0A        setRGB(128, 128, 0)%0A        response = %22'%22 + msg + %22' is now shown on the LCD screen%22%0A    except:%0A        response = %22There was an error showing the message on the LCD screen%22%0A%0A    return response%0A%0A# If no URL specified, show the date and time%0A@app.route(%22/%22)%0Adef hello():%0A    now = datetime.datetime.now()%0A    timeString = now.strftime(%22%25Y-%25m-%25d %25H:%25M%22)%0A    return timeString%0A%0A# Force the web browser not to cache our requests. Sometimes with caching on, the web browser may show the previous result instead of calling our server.%0A@app.after_request%0Adef add_header(response):%0A    response.cache_control.max_age = 0%0A    return response%0A%0Aif __name__ == %22__main__%22:%0A    app.run(host='0.0.0.0', port=80, debug=True)%0A

Create server.py