예제 #1
0
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})
예제 #2
0
def get(request):
    return json({
        'args': {},
        'headers': headers_dict(request.headers),
        'origin': request.remote_addr,
        'url': request.url,
    }, pretty=True)
예제 #3
0
def get(request):
    return json(
        {
            'args': {},
            'headers': headers_dict(request.headers),
            'origin': request.remote_addr,
            'url': request.url,
        },
        pretty=True)
예제 #4
0
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']
예제 #5
0
def err_response(exc):
    return json({
        'msg': exc.message,
    }, pretty=True, code=exc.status_code)
예제 #6
0
def headers(request):
    return json({
        'headers': headers_dict(request.headers),
    }, pretty=True)
예제 #7
0
def user_agent(request):
    return json({
        'user-agent': request.headers.get('User-Agent'),
    }, pretty=True)
예제 #8
0
def ip(request):
    return json({
        'origin': request.remote_addr,
    }, pretty=True)
예제 #9
0
def list_tasks(request):
    return json({'tasks': tasks})
예제 #10
0
def err_response(exc):
    return json({
        'msg': exc.message,
    }, pretty=True, code=exc.status_code)
예제 #11
0
def headers(request):
    return json({
        'headers': headers_dict(request.headers),
    }, pretty=True)
예제 #12
0
def user_agent(request):
    return json({
        'user-agent': request.headers.get('User-Agent'),
    },
                pretty=True)
예제 #13
0
def ip(request):
    return json({
        'origin': request.remote_addr,
    }, pretty=True)