Skip to content

Commit

Permalink
show request information in test app
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbusch committed Feb 18, 2020
1 parent e47a3d8 commit 8e4e9cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from flask import Flask

from flask_tex import render_to_pdf
from flask_tex import render_to_pdf, TeX


app = Flask(__name__)
TeX(app)


@app.route("/")
def index():
return render_to_pdf("test.tex", foo="Hello World")
return render_to_pdf("index.tex", foo="Hello World")
31 changes: 31 additions & 0 deletions tests/templates/index.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\documentclass{article}
\usepackage{tabularx}

\title{Using \LaTeX{} with Flask should be a lot of fun}

\begin{document}
\maketitle
\section{ {{- foo -}} }

This is your request data:

\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|}
\hline Url & {{ request.url | latex_escape }} \\
\hline Method & {{ request.method | latex_escape }} \\
\hline Access route & {{ ' > '.join(request.access_route) | latex_escape }} \\
{% for key, value in request.headers.items() %}
\hline
{{ key | latex_escape }} &
{%- if key == 'Accept' -%}
{{ ', '.join(value.split(',')) | latex_escape }}
{%- else -%}
{{ value | latex_escape }}
{%- endif -%}
\\
{% endfor %}
\hline
\end{tabularx}
\end{table}

\end{document}

0 comments on commit 8e4e9cf

Please sign in to comment.