Yu Da Chi
Yu Da Chi

Reputation: 109

Propper way of URL building on Flask

I want to have url like this /csv/table and I have it, but it doesn't work, give me an error

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Here is pug code for upload form

form(method='post' action="{{ url_for('table', root=url_for('upload')) }}"

and flask routes

@app.route('/', methods=['GET'])
def index():
    return render_template('index.html')

@app.route('/csv/', methods=['GET', 'POST'])
def upload():
    return render_template('upload.html')

@app.route('/<root>table', methods=['POST'])
def table(root):
    return render_template('table.html', root=root)

Upvotes: 0

Views: 37

Answers (1)

Yu Da Chi
Yu Da Chi

Reputation: 109

thanks @reportgunner =)

problem was in /csv/ route and button for my second page a(href blah-blah-blah

I created propper form with action and now all works fine

except first level url, which is have trailing question mark now http://127.0.0.1:5000/csv? heh

Upvotes: 1

Related Questions