-1

I have deployed my Flask python application on Heroku. The problem is that in one line of my python code I must open an HTML file (where some javascript gets executed).

Obviously, it locally works in my mac, but in Heroku it doesn't' seem to recognise the 'open' command, in fact I get:

/bin/sh: 1: open: not found

This is the python code in my script:
p = Popen('open last.html', shell=True)

Is there a way to solve this and get the HTML file to be opened? Thanks

PGC PGC
  • 1
  • 1
  • 1
    Just to be clear, what's your goal here? What is this supposed to accomplish? Are you trying to see a web browser window on your screen rendering your `last.html` file? In other words, specifically what do you mean by "in one line of my python code I must open an HTML file (where some javascript gets executed)"? – ChrisGPT was on strike Apr 09 '19 at 20:09
  • I have 3 python scripts that get executed in a sequence, they do some Apis calls, I had to use javascript for the final Apis call (Last.FM). In order to do that I created an HTML file, put the javascript inside, which gets executed every time it gets opened in the web browser. Popen('open last.html', shell=True) this command automatically opens the file in my mac, while it doesn't work on Heroku bash because it doesn't recognise the "open" command. I need the file to be opened to get the javascript executed. – PGC PGC Apr 10 '19 at 08:01
  • So the point isn't to see the page open, but to run that JavaScript code? It doesn't matter if you don't see it, just that it runs? – ChrisGPT was on strike Apr 10 '19 at 11:33
  • That doesn't help much. That code has side effects, interacting with Firebase and then POSTing data to Audioscrobbler, which means it might be useful to run without seeing the browser. But it also displays data, suggesting that you need to see it. _Again_, are you running this for its side effects or to see the browser? (In the future, please don't link to off-site resources when sharing code. Instead, paste a [mcve] directly into your question.) – ChrisGPT was on strike Apr 10 '19 at 13:04

1 Answers1

-1

Try Popen(['/bin/bash', '-c', 'open last.html'])

Murilo
  • 21
  • 4
  • 1
    One line answers with no explanation are not very useful. Please provide an explanation of why you think this form will succeed where the origianl failed. – NickD Apr 09 '19 at 20:15