-1

I want to open multiple urls in separate tabs in my flask app

using following code only first url gets opened.

 @app.route('/get_spot', methods=["GET", "POST"])
def spot():
    urls =['https://www.geeksforgeeks.org/puzzles/','https://www.careerbless.com/aptitude/qa/home.php','https://web.whatsapp.com/']
    
    for url in urls:
        return redirect(url)

I have tried using selenium webdriver, which is very slow, and creates new window on each call.

driver = webdriver.Chrome()
for url in urls:
    driver.execute_script('window.open("{}", "_blank");'.format(url))
davidism
  • 121,510
  • 29
  • 395
  • 339

1 Answers1

0

You need to do this in JavaScript with the window.open function, see https://stackoverflow.com/a/14132265/672833

You could create a loop in JavaScript and open one will window after another.

The JavaScript needs to be called/triggered in a template file.

Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37