-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show request information in test app
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |