def rst2html(): rst = request.form.get('rst', '') theme = request.form.get('theme') if theme == 'basic': theme = None html = _rst2html(rst, theme=theme) return html
def rst2html(): rst = request.form.get('rst', '') with open('/tmp/presentacion.rst','w') as tmpfile: tmpfile.write(rst) theme = request.form.get('theme') if theme == 'slides': g = LandSlide("/tmp/presentacion.rst", embed=True) html = g.render() else: if theme == 'basic': theme = None html = _rst2html(rst, theme=theme) return html
def convert_file(): if request.method == 'POST': file = request.files['rstFile'] rst = '' convert_to = request.form.get('convert_to') if file and allowed_file(file.filename): rst = file.read() if convert_to == 'html': html = _rst2html(rst, theme="nature"); html_bz = bz2.compress(html) response = make_response(html_bz) response.headers["Content-Disposition"] = "attachment; filename=" + file.filename + ".html.bz2" return response else if convert_to == 'pdf': return redirect(url_for('convert', reason='unsupported format')) return redirect(url_for('convert'))