raspiled/webapp.py

48 lines
809 B
Python

#!/usr/bin/env python3
# encoding: utf-8
from flask import Flask
import led
app = Flask(__name__)
@app.route('/')
def index():
return "Benvenuto nel raspberry."
@app.route('/accendi')
@app.route('/on')
def accendi():
led.pin_on()
if led.stato_pin():
return "LED acceso."
return "LED Spento."
@app.route('/spegni')
@app.route('/off')
def spegni():
led.pin_off()
if led.stato_pin():
return "LED acceso."
return "LED spento."
@app.route('/toggle')
def toggle():
led.toggle()
if led.stato_pin():
return "Il LED è acceso."
return "Il LED è spento."
@app.route('/lampeggia')
def lampeggia():
led.lampeggia()
return "LED ha lampeggiato."
if __name__ == '__main__':
with app.app_context():
led.setup()
app.run()