Flask Redirect New Tab

后端 未结 3 1149
佛祖请我去吃肉
佛祖请我去吃肉 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: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')
    

提交回复
热议问题