1Web development with Flask
2==========================
3
4`Flask <https://palletsprojects.com/p/flask/>`__ is a popular framework for building web apps in Python.
5
6Flask tutorials usually instruct running Flask programs by entering some commands in Terminal,
7but this may intimidate some beginners. Thonny tries make things easeir and allows running Flask programs
8just like any other program (with simple F5). If it detects you are running a Flask program, then it executes
9it with some lines of code appended, which start the development server with suitable settings.
10
11Debugging
12---------
13If you want to step through your Flask program, set a breakpoint inside some function and invoke
14the debugger (both nicer and faster work, but faster is ... faster). Reload your page and start
15stepping inside the function. You may want to turn off "Frames in separate windows" (Tools => Options
16=> Run & Debug) for more comfortable operation.
17
18Details
19-------
20Thonny will start the development server approximately like this:
21
22.. code::
23
24	os.environ["FLASK_ENV"] = "development"
25	app.run(threaded=False, use_reloader=False, debug=False)
26
27``threaded=False`` is used because Thonny's debugger supports only single-threaded programs,
28``use_reloader=False`` is used because
29`automatic reloading is not reliable when Flask is started like this <https://flask.palletsprojects.com/en/1.0.x/api/#flask.Flask.run>`_
30and ``debug=False`` is used because this seems to cause less "Address already in use" errors.
31
32If you want more control over the settings then you should call the ``run``-method yourself,
33eg:
34
35.. code::
36
37	...
38	if __name__ == "__main__":
39		app.run(port=5005, threaded=False, use_reloader=True, debug=True)
40
41In this case Thonny won't add anything to your code.
42