Forum Archive

Webapp Debugging

myko

How can I debug my webapp in Pythonista? In the python learning book they use this code:

app.run(debug=True)

It doesn't function in Pythonista and I get these messages:
* Running on http://127.0.0.1:5000/
* Restarting with reloader
and some error messages.
Here is my webapp code:

from flask import Flask, render_template


app = Flask(__name__)

@app.route('/') 
def hello() -> str:
    return 'Hello world from Flask!'

@app.route('/search4', methods=['POST']) 
def do_search() -> str:
    return str(search4letters('life, the universe and everything','eiru,!'))

@app.route('/entry') 
def entry_page() -> 'html':
    return render_template('entry.html', the_title='Welcome to search for letters on the web!')

app.run(debug=True)

omz

Flask's auto-reloader doesn't work in Pythonista because it would require spawning subprocesses which isn't possible on iOS.

You can pass use_reloader=False to app.run() though, and debugging should still work.