@app.route('/status', methods=['GET'])
def status():
    import os, time
    now = datetime.datetime.now()
    timeString = now.strftime('%Y-%m-%d %H:%M')
    details = {'time': timeString}
    if (temperature and app.config['TEMPERATURE']):
        tempcelsius = temperature.get_temperature()
        details.update({'temperature': tempcelsius})
    if os.path.exists(motionfile):
        details['motion'] = time.ctime(os.path.getmtime(motionfile))
    if app.config['WEBCAM']:
        import sh, os
        timeString = now.strftime('%Y%m%d_%H%M')
        snapshot = ('snapshot-%s.jpg' % timeString)
        snapshot = os.path.join('static', 'webcam', snapshot)
        details['webcam'] = ('/' + snapshot)
        snapshot = os.path.abspath(snapshot)
        if (not os.path.exists(snapshot)):
            sh.fswebcam('--title', 'Home', '--save', snapshot)
    return jsonify(**details)
@app.route('/status', methods=['GET'])
def status():
    import os, time
    now = datetime.datetime.now()
    timeString = now.strftime('%Y-%m-%d %H:%M')
    details = {'time': timeString}
    if (temperature and app.config['TEMPERATURE']):
        tempcelsius = temperature.get_temperature()
        details.update({'temperature': tempcelsius})
    if os.path.exists(motionfile):
        details['motion'] = time.ctime(os.path.getmtime(motionfile))
    if app.config['WEBCAM']:
        import sh, os
        timeString = now.strftime('%Y%m%d_%H%M')
        snapshot = ('snapshot-%s.jpg' % timeString)
        snapshot = os.path.join('static', 'webcam', snapshot)
        details['webcam'] = ('/' + snapshot)
        snapshot = os.path.abspath(snapshot)
        if (not os.path.exists(snapshot)):
            sh.fswebcam('--title', 'Home', '--save', snapshot)
    return jsonify(**details)