Ejemplo n.º 1
0
from bottle import response, template, static_file, request
import json
import time
from owntracks import cf
from owntracks.dbschema import db, User, Acl, Params, fn, Location, createalltables
import paho.mqtt.client as paho
from owntracks.auth import PistaAuth

log = logging.getLogger(__name__)

cacert_file = cf.g('ctrld', 'cacert_file')
if not os.path.isfile(cacert_file) or not os.access(cacert_file, os.R_OK):
    log.error("Cannot open cacert_file ({0})".format(cacert_file))
    sys.exit(2)

createalltables()

auth = PistaAuth()

app = application = bottle.Bottle()

def notauth(reason):
    return bottle.HTTPResponse(status=403, body=json.dumps({"message": reason}))

@app.route('/')
def show_index():
    return "Hola!"

@app.route('/conf', method='POST')
def conf():
    resp = {}
Ejemplo n.º 2
0
from bottle import response, template, static_file, request
import json
import time
from owntracks import cf
from owntracks.dbschema import db, User, Acl, Params, fn, Location, createalltables
import paho.mqtt.client as paho
from owntracks.auth import PistaAuth

log = logging.getLogger(__name__)

cacert_file = cf.g('ctrld', 'cacert_file')
if not os.path.isfile(cacert_file) or not os.access(cacert_file, os.R_OK):
    log.error("Cannot open cacert_file ({0})".format(cacert_file))
    sys.exit(2)

createalltables()

auth = PistaAuth()

app = application = bottle.Bottle()


def notauth(reason):
    return bottle.HTTPResponse(status=403,
                               body=json.dumps({"message": reason}))


@app.route('/')
def show_index():
    return "Hola!"