def get_task(request, task_id): task_id = int(task_id) try: task = tasks[task_id] except IndexError: raise HTTPException(404) return json({'task': task})
def get(request): return json({ 'args': {}, 'headers': headers_dict(request.headers), 'origin': request.remote_addr, 'url': request.url, }, pretty=True)
def get(request): return json( { 'args': {}, 'headers': headers_dict(request.headers), 'origin': request.remote_addr, 'url': request.url, }, pretty=True)
def test_json(): resp = json({'greeting': 'Hello World!'}) assert resp.headers['Content-Type'] == 'application/json; charset=utf-8' assert list(resp) == [b'{"greeting":"Hello World!"}\n']
def err_response(exc): return json({ 'msg': exc.message, }, pretty=True, code=exc.status_code)
def headers(request): return json({ 'headers': headers_dict(request.headers), }, pretty=True)
def user_agent(request): return json({ 'user-agent': request.headers.get('User-Agent'), }, pretty=True)
def ip(request): return json({ 'origin': request.remote_addr, }, pretty=True)
def list_tasks(request): return json({'tasks': tasks})