Executing a python script using Flask [duplicate]
This question already has an answer here:
Flask view raises TypeError: 'bool' object is not callable
1 answer
I trying to executing a Python script through Flask.
I wrote below python code to execute another python script.
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("/home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
#return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
But unfortunately when I run above python code and check the 127.0.0.1:5000 It's giving this error in browser :
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
Any solution?
My ultimate goal is to open a python script via HTML page's Button.
python flask
marked as duplicate by davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 13:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Flask view raises TypeError: 'bool' object is not callable
1 answer
I trying to executing a Python script through Flask.
I wrote below python code to execute another python script.
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("/home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
#return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
But unfortunately when I run above python code and check the 127.0.0.1:5000 It's giving this error in browser :
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
Any solution?
My ultimate goal is to open a python script via HTML page's Button.
python flask
marked as duplicate by davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 13:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Flask view raises TypeError: 'bool' object is not callable
1 answer
I trying to executing a Python script through Flask.
I wrote below python code to execute another python script.
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("/home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
#return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
But unfortunately when I run above python code and check the 127.0.0.1:5000 It's giving this error in browser :
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
Any solution?
My ultimate goal is to open a python script via HTML page's Button.
python flask
This question already has an answer here:
Flask view raises TypeError: 'bool' object is not callable
1 answer
I trying to executing a Python script through Flask.
I wrote below python code to execute another python script.
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("/home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
#return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
But unfortunately when I run above python code and check the 127.0.0.1:5000 It's giving this error in browser :
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
Any solution?
My ultimate goal is to open a python script via HTML page's Button.
This question already has an answer here:
Flask view raises TypeError: 'bool' object is not callable
1 answer
python flask
python flask
asked Nov 21 '18 at 6:45
dishcodedishcode
86
86
marked as duplicate by davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 13:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 13:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
As a response, you have to return from the function. so you can do like this
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("python /home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
return "ok"
if __name__ == "__main__":
app.run(debug=True)
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As a response, you have to return from the function. so you can do like this
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("python /home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
return "ok"
if __name__ == "__main__":
app.run(debug=True)
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
add a comment |
As a response, you have to return from the function. so you can do like this
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("python /home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
return "ok"
if __name__ == "__main__":
app.run(debug=True)
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
add a comment |
As a response, you have to return from the function. so you can do like this
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("python /home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
return "ok"
if __name__ == "__main__":
app.run(debug=True)
As a response, you have to return from the function. so you can do like this
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def home():
subprocess.call("python /home/tech/Downloads/labelme-master/labelme/main.py 1", shell=True)
return "ok"
if __name__ == "__main__":
app.run(debug=True)
edited Nov 21 '18 at 7:05
answered Nov 21 '18 at 6:51
RamRam
385112
385112
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
add a comment |
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
any idea how to run above python script using html Button?
– dishcode
Nov 21 '18 at 7:00
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
You can make ajax call from javascript
– Ram
Nov 21 '18 at 7:09
add a comment |