示例#1
0
def get_html(path):
    template_file = path.strip('/')
    template_path = os.getcwd() + '/templates/' + template_file

    if os.path.exists(template_path + '.html'):
        template_format = 'html'
        template_src = templateEnv.get_template(template_file + '.html')
    elif os.path.exists(template_path + '.md'):
        template_format = 'md'
        template_src = templateEnv.get_template(template_file + '.md')
    else:
        return 'path: %s does not exist' % path, 404

    print template_path

    # print request.headers
    # ipdb.sset_trace()
    result = ''

    try:
        result = template_src.render(request.get_json(
        ) if request.method == 'POST' else deserialize(request.query_string))
    except Exception, e:
        return jsonify({'message': str(e)}), 400
示例#2
0
def test_url():
    qs = r'origin[url]=https%3A%2F%2Fwww.example.com%2Fitem%2Fitem_id'
    result = deserialize(qs)
    assert result == {
        'origin': {'url': 'https://www.example.com/item/item_id'}
    }
示例#3
0
def test_brackets_start():
    qs = r'hola=caracola&adios=caracol&foo=bar&[nested]value=foobar'
    assert deserialize(qs) == result_1
示例#4
0
def test_brackets():
    qs = r'hola=caracola&adios=caracol&foo=bar&nested[value]=foobar'
    assert deserialize(qs) == result_1
示例#5
0
def test_dots():
    qs = r'hola=caracola&adios=caracol&foo=bar&nested.value=foobar'
    assert deserialize(qs) == result_1
示例#6
0
def test_data1_2():
    assert deserialize(serialize(data_1)) == data_1