I use pdf.js to render pdf in web. The format of the target url like this:
http://www.example.com/book?file=abc.pdf
My problem is: I use flask template to generate page using:
return render_template('book.html', paraKey=paraValue)
But how to attach url parameter "file=abc.pdf" to url? The parameter will be read by viewer.js(included in book.html) that uses it to read file for rendering pdf.
I'm new to flask, hoping guys giving me some help!
You could use redirect function, which can redirect you whatever you want:
@app.route('/book')
def hello():
file = request.args.get('file')
if not file:
return redirect("/?file=abc.pdf")
return render_template('book.html', paraKey=paraValue)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With