I have a simple flask application:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
text = '<h2>Text: </h2><form><input name="firstname" type="text">'
select = '<h2>Select: </h2><select name="cars">' + \
'<option value="volvo">Volvo</option>' + \
'<option value="saab">Saab</option>' + \
'<option value="fiat">Fiat</option> ' + \
'<option value="audi">Audi</option>' + \
'</select>'
multiselect = '<h2>Multiselect: </h2><select name="mCars" multiple>' + \
'<option value="volvo">Volvo</option>' + \
'<option value="saab">Saab</option>' + \
'<option value="fiat">Fiat</option> ' + \
'<option value="audi">Audi</option>' + \
'</select>'
textarea = '<h2>Textarea: </h2><textarea name="message" rows="10" cols="30">' + \
'The cat was playing in the garden.' + \
'</textarea>'
button = '<h2>Button</h2><button type="button" onclick="alert(\'Hello World!\')">Click Me!</button>'
# datalist = '<h2>Datalist</h2><datalist id="browsers">' + \
# '<option value="Internet Explorer">' + \
# '<option value="Firefox">' + \
# '<option value="Chrome">' + \
# '<option value="Opera">' + \
# '<option value="Safari">' + \
# '</datalist> '
return '<h1>Sample Form</h1>' + \
text + \
select + \
multiselect + \
textarea + \
button
if __name__ == '__main__':
app.run()
When I run the file itself it runs:
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
I'm trying to run it from a runner file and continue execution of the file. It stops executing when flask runs. I've tried the following.
os.system('python ' + get_driver_file_path(Settings.TestProjectPath))
I think this makes sense because I am just running it.
I tried and it also runs but stops execution:
subprocess.call([Settings.PythonExecutablePath, get_driver_file_path(Settings.TestProjectPath)])
I tried:
server = Popen(get_driver_file_path(Settings.TestProjectPath), stdout=PIPE, stderr=PIPE, shell=True)
This does not seem to do anything.
How can I get it to run the flask server and continue execution?
gunicorn? Specifically, what is the command you would execute to run the app as blocking?FLASK_APP=api.py,FLASK_ENV=production,FLASK_DEBUG=0and finally callingflask run, is that correct?app = Flask(__name__)thenapp.run()in the script file.