Flask Redirect New Tab

后端 未结 3 1144
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 15:03

Does anyone know if flask redirect is able to open a link / URL in a new tab?

@app.route(\'/test\')
def my_page():

  return redirect(\'http://mylink.com\',          


        
相关标签:
3条回答
  • 2021-01-05 15:46

    If you're dealing with a form you can set target="_blank"

    0 讨论(0)
  • 2021-01-05 15:54

    As far as I know that would not be a flask issue. You have to open a new tab within your html code or with Javascript.

    example: <a href="http://mylink.com" target="_blank">Link</a>

    The server has no power over what the browser does in this case.

    0 讨论(0)
  • 2021-01-05 15:59

    You could also use Python's webbrowser module to open a page, if you'd like to avoid getting into the HTML

    import webbrowser
    
    @app.route('/test')
    def my_page():
        return webbrowser.open_new_tab('http://mylink.com')
    
    0 讨论(0)
提交回复
热议问题