Click a form button to open a new tab in flask

Unfortunately online support for flask is somewhat limited. It is not treated as a mature web programming language. But I use it mainly for internal demo purpose, and it simplifies things tremendously. The trick is often that a technique is not specific to flask, but html in general.

It is relatively easy to redirect to a new tab with a hyperlink in html:

<a href=”google.com” target=”_blank”> my awesome link </a>

will do that.

With forms, target is a top level attribute that controls rendering of the entire form

<form target=”_blank”> … <input type=”submit” value=”submit”> … </form>

To redirect to new tab for an individual button within the form, try

<form> … <input type=”submit” value=”submit” formtarget=”_blank” > … </form>

I also found that POST actions do not support Ctrl + Click, since the target url cannot infer the POST parameters directly.

Several useful links on flask:

 

Advertisements

About aquazorcarson

math PhD at Stanford, studying probability
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s