Example #1
0
from flask import Flask, request, session, g, redirect, url_for, \
     abort, render_template, flash, Response, send_from_directory
import time
from bluepy import btle
import logging
import server_settings

app = Flask(__name__)
app.config.from_object(__name__)
# WARNING: For some reason, setting Flask DEBUG=True causes btle to fail
app.config["PROPOGATE_EXCEPTIONS"] = True

# Log to stdout
logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s]  %(message)s")
rootLogger = logging.getLogger()
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)

notification_data = False # Buffer to store data from BTLE. False if nothing yet read or data already read
temperature = None # None if not yet loaded
visor_status = None

debug = True

response_prefix = """
<html>
<head>
<title>CAT COMMANDER</title>
</head>
<body>