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
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'} }
def test_brackets_start(): qs = r'hola=caracola&adios=caracol&foo=bar&[nested]value=foobar' assert deserialize(qs) == result_1
def test_brackets(): qs = r'hola=caracola&adios=caracol&foo=bar&nested[value]=foobar' assert deserialize(qs) == result_1
def test_dots(): qs = r'hola=caracola&adios=caracol&foo=bar&nested.value=foobar' assert deserialize(qs) == result_1
def test_data1_2(): assert deserialize(serialize(data_1)) == data_1