forked from orbit-oss/flask
Merge pull request #427 from kevinburke/fix-existing-tutorial
add heroku/deploy options to quickstart, and add clearer links in tutorial setup
This commit is contained in:
commit
1d1db80e06
2 changed files with 26 additions and 10 deletions
|
|
@ -826,3 +826,19 @@ can do it like this::
|
||||||
|
|
||||||
from werkzeug.contrib.fixers import LighttpdCGIRootFix
|
from werkzeug.contrib.fixers import LighttpdCGIRootFix
|
||||||
app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
|
app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
|
||||||
|
|
||||||
|
Deploying to a Web Server
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
If you want to make your Flask app available to the Internet at large, `Heroku
|
||||||
|
<http://www.heroku.com>`_ is very easy to set up and will run small Flask
|
||||||
|
applications for free. `Check out their tutorial on how to deploy Flask apps on
|
||||||
|
their service <http://devcenter.heroku.com/articles/python>`_.
|
||||||
|
|
||||||
|
There are a number of other websites that will host your Flask app and make it
|
||||||
|
easy for you to do so.
|
||||||
|
|
||||||
|
- `Deploying Flask on ep.io <https://www.ep.io/docs/quickstart/flask/>`_
|
||||||
|
- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_
|
||||||
|
- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_
|
||||||
|
- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ into the module which we will be doing here. However a cleaner solution
|
||||||
would be to create a separate `.ini` or `.py` file and load that or import
|
would be to create a separate `.ini` or `.py` file and load that or import
|
||||||
the values from there.
|
the values from there.
|
||||||
|
|
||||||
::
|
In `flaskr.py`::
|
||||||
|
|
||||||
# all the imports
|
# all the imports
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
@ -26,7 +26,7 @@ the values from there.
|
||||||
PASSWORD = 'default'
|
PASSWORD = 'default'
|
||||||
|
|
||||||
Next we can create our actual application and initialize it with the
|
Next we can create our actual application and initialize it with the
|
||||||
config from the same file::
|
config from the same file, in `flaskr.py`::
|
||||||
|
|
||||||
# create our little application :)
|
# create our little application :)
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
@ -37,21 +37,21 @@ string it will import it) and then look for all uppercase variables
|
||||||
defined there. In our case, the configuration we just wrote a few lines
|
defined there. In our case, the configuration we just wrote a few lines
|
||||||
of code above. You can also move that into a separate file.
|
of code above. You can also move that into a separate file.
|
||||||
|
|
||||||
It is also a good idea to be able to load a configuration from a
|
Usually, it is a good idea to load a configuration from a configurable
|
||||||
configurable file. This is what :meth:`~flask.Config.from_envvar` can
|
file. This is what :meth:`~flask.Config.from_envvar` can do, replacing the
|
||||||
do::
|
:meth:`~flask.Config.from_object` line above::
|
||||||
|
|
||||||
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
|
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
|
||||||
|
|
||||||
That way someone can set an environment variable called
|
That way someone can set an environment variable called
|
||||||
:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will
|
:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will then
|
||||||
then override the default values. The silent switch just tells Flask to
|
override the default values. The silent switch just tells Flask to not complain
|
||||||
not complain if no such environment key is set.
|
if no such environment key is set.
|
||||||
|
|
||||||
The `secret_key` is needed to keep the client-side sessions secure.
|
The `secret_key` is needed to keep the client-side sessions secure.
|
||||||
Choose that key wisely and as hard to guess and complex as possible. The
|
Choose that key wisely and as hard to guess and complex as possible. The
|
||||||
debug flag enables or disables the interactive debugger. Never leave
|
debug flag enables or disables the interactive debugger. *Never leave
|
||||||
debug mode activated in a production system because it will allow users to
|
debug mode activated in a production system*, because it will allow users to
|
||||||
execute code on the server!
|
execute code on the server!
|
||||||
|
|
||||||
We also add a method to easily connect to the database specified. That
|
We also add a method to easily connect to the database specified. That
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue