Ejemplo n.º 1
0
def hello():
    printer.merge_connected_with_config(printer.find_printers(), cfg)
    return template('index', api_key=cfg.api_key)
Ejemplo n.º 2
0
def scan_printers(apikey):
    if apikey != cfg.api_key:
        abort(403, "Access Denied")
    printer.merge_connected_with_config(printer.find_printers(), cfg)
    cfg.write()
    return dict(printers=cfg.printers)
Ejemplo n.º 3
0
import sys

# load config ##
cfg = Config()

# logging
log_level = logging.DEBUG if cfg.debug else logging.INFO
logging.basicConfig(level=log_level)
logger = logging.getLogger("server")

# ping thread ##
ping_thing = ping.Pinger(cfg)
ping_thing.start()

# update printer list in config ##
printer.merge_connected_with_config(printer.find_printers(), cfg)

# write out latest config ##
cfg.write()


@hook('after_request')
def enable_access_controls():
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Access-Control-Allow-Methods'] = 'PUT, GET, POST, DELETE, OPTIONS'
    response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'


@route('/log')
def get_log():
    return "Not yet!"