<commit_before>import picoweb
from wlan.ap import model
from util import notFound, error

def get(req, res):
  yield from picoweb.jsonify(res, model.get())

def set(req, res):
  yield from req.read_form_data()
  opts = {
    'essid': req.form.get('essid', [''])[0],
    'password': req.form.get('password', [''])[0]
  }
  if not opts['essid']:
    yield from error(req, res, 'empty essid')
    return
  if len(opts['password']) < 8:
    yield from error('"password min length 8"')
    return
  model.set(opts)
  yield from get(req, res)

def method(req, res):
  ret = {
    'GET': get,
    'PUT': set
  }
  yield from ret.get(req.method, notFound)(req, res)

app = picoweb.WebApp(__name__)
app.route('/')(method)<commit_msg>add paramenter for error handler<commit_after>import picoweb
from wlan.ap import model
from util import notFound, error

def get(req, res):
  yield from picoweb.jsonify(res, model.get())

def set(req, res):
  yield from req.read_form_data()
  opts = {
    'essid': req.form.get('essid', [''])[0],
    'password': req.form.get('password', [''])[0]
  }
  if not opts['essid']:
    yield from error(req, res, 'empty essid')
    return
  if len(opts['password']) < 8:
    yield from error(req, res, 'password min length 8')
    return
  model.set(opts)
  yield from get(req, res)

def method(req, res):
  ret = {
    'GET': get,
    'PUT': set
  }
  yield from ret.get(req.method, notFound)(req, res)

app = picoweb.WebApp(__name__)
app.route('/')(method)
{'fraction_non_alphanumeric': 0.168135593220339, 'fraction_numerical': 0.005423728813559322, 'mean_word_length': 3.7766990291262137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3599987', 'n_tokens_mistral': 545, 'n_tokens_neox': 543, 'n_words': 149}