0

I am making every path lead to index.html, since it is a single page app. I made a blueprint called mod and put all the restul api there using flask-restful

@mod.route('/')
@mod.route('/<path:p>')
def home(p=0):
    return render_template('index.html')

is this right way to do it? I am little concerned about p=0 part. the variable p is never used, but has to be there since it has to receive path variable p

Keon Kim
  • 740
  • 3
  • 12
  • 27
  • `p=0` shouldn't matter if you are never using the variable `p`, but might this logic be implemented in the server config? – Paul Rooney May 05 '15 at 10:16

1 Answers1

2

Your routing is certainly reasonable.

A more simple/readible way of doing it might be:

@mod.route('/')
@mod.route('/<path>')
def home(*args, **kwargs):
    return render_template('index.html')

From an efficiency standpoint its probably better to handle this entirely on the webserver (nginx/apache/whatever).

Carson Crane
  • 1,197
  • 8
  • 15