Skip to content

Commit 9219229

Browse files
committed
runserver: Debugging now defaults to whatever the app's configuration says
or True if that's None. Also, print a warning when debugging is on.
1 parent 1eceadc commit 9219229

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

docs/index.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,12 @@ See the :ref:`api` below for details on the various prompt functions.
404404
Default commands
405405
----------------
406406

407+
runserver
408+
+++++++++
409+
407410
**Flask-Script** has a couple of ready commands you can add and customise: ``Server`` and ``Shell``.
408411

409-
The ``Server`` command runs the **Flask** development server. It takes an optional ``port`` argument (default **5000**)::
412+
The ``Server`` command runs the **Flask** development server.
410413

411414
from flask.ext.script import Server, Manager
412415
from myapp import create_app
@@ -427,6 +430,26 @@ The ``Server`` command has a number of command-line arguments - run ``python man
427430

428431
Needless to say the development server is not intended for production use.
429432

433+
*New in version 2.0.5*
434+
435+
The most common use-case for ``runserver`` is to run a debug server for
436+
investigating problems. Therefore the default, if it is *not* set in the
437+
configuration file, is to enable debugging and auto-reloading.
438+
439+
Unfortunately, Flask currently (as of May 2014) defaults to set the DEBUG
440+
configuration parameter to ``False``. Until this is changed, you can
441+
safely add ``DEFAULT=None`` to your Flask configuration. Flask-Script's
442+
``runserver`` will then turn on debugging, but everything else will treat
443+
it as being turned off.
444+
445+
To prevent misunderstandings -- after all, debug mode is a serious security
446+
hole --, a warning is printed when Flask-Script treats a ``None`` default
447+
value as if it were set to ``True``. You can turn on debugging explicitly
448+
to get rid of this warning.
449+
450+
shell
451+
+++++
452+
430453
The ``Shell`` command starts a Python shell. You can pass in a ``make_context`` argument, which must be a ``callable`` returning a ``dict``. By default, this is just a dict returning the your Flask application instance::
431454

432455
from flask.ext.script import Shell, Manager

flask_script/commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import absolute_import
33

44
import os
5+
import sys
56
import code
67
import warnings
78
import string
@@ -407,6 +408,10 @@ def __call__(self, app, host, port, use_debugger, use_reloader,
407408

408409
if use_debugger is None:
409410
use_debugger = app.debug
411+
if use_debugger is None:
412+
use_debugger = True
413+
if sys.stderr.isatty():
414+
print("Debugging is on. DANGER: Do not allow random users to connect to this server.", file=sys.stderr)
410415
if use_reloader is None:
411416
use_reloader = app.debug
412417
app.run(host=host,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
setup(
2929
name='Flask-Script',
30-
version='2.0.4',
30+
version='2.0.5',
3131
url='http://github.com/smurfix/flask-script',
3232
download_url = 'https://github.com/smurfix/flask-script/tarball/v2.0.3',
3333
license='BSD',

0 commit comments

Comments
 (0)