I would like to create a web service from a simple invoice app I have wrote. I would like it to return json and hopefully pdf files from apache fop. I do not want a html web page, I will access the service from python desktop application.
Can I ignore the template section of the documentation?
The most trouble I am having is accepting multiple parameters for a function.
How do I turn the sample code below into accepting multiple inputs?
@app.route('/post/<int:post_id>')
def show_post(post_id):
# show the post with the given id, the id is an integer
return 'Post %d' % post_id
I am new to programming and even more so to web services, if I am going about this in the wrong manner please let me know.
You sure can ignore the html section. Flask is a nice lightweight way to create a web app. You can just return json (or other data) as responses to all your urls if you want and completely disregard the html templateing.
You can include as many params/regexes as you need in your route definition Each one will create a new param for the function.
Does Flask support regular expressions in its URL routing?