Skip to content
Myr

Merge pull request #427 from kevinburke/fix-existing-tutorial

Before adoption: this commit came in with the history the project adopted, so no landing records it.

add heroku/deploy options to quickstart, and add clearer links in tutorial setup

authored by Ron DuPlain · committed by Ron DuPlain · parents 4e9b786, 2befab2 · Browse files · 2 files+26 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−10 removed

  • other:+26 added−10 removed

2 files+26 added−10 removed

modified:docs/tutorial/setup.rst+10 added-10 removed
9 unmodified lines
10into the module which we will be doing here. However a cleaner solution11would be to create a separate `.ini` or `.py` file and load that or import12the values from there.1314::14In `flaskr.py`::1516 # all the imports17 import sqlite318 from flask import Flask, request, session, g, redirect, url_for, \
6 unmodified lines
25 USERNAME = 'admin'26 PASSWORD = 'default'2728Next we can create our actual application and initialize it with the29config from the same file::29config from the same file, in `flaskr.py`::3031 # create our little application :)32 app = Flask(__name__)33 app.config.from_object(__name__)
2 unmodified lines
36string it will import it) and then look for all uppercase variables37defined there. In our case, the configuration we just wrote a few lines38of code above. You can also move that into a separate file.3940It is also a good idea to be able to load a configuration from a41configurable file. This is what :meth:`~flask.Config.from_envvar` can42do::40Usually, it is a good idea to load a configuration from a configurable41file. This is what :meth:`~flask.Config.from_envvar` can do, replacing the42:meth:`~flask.Config.from_object` line above::4344 app.config.from_envvar('FLASKR_SETTINGS', silent=True)4546That way someone can set an environment variable called47:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will48then override the default values. The silent switch just tells Flask to49not complain if no such environment key is set.47:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will then48override the default values. The silent switch just tells Flask to not complain49if no such environment key is set.5051The `secret_key` is needed to keep the client-side sessions secure.52Choose that key wisely and as hard to guess and complex as possible. The53debug flag enables or disables the interactive debugger. Never leave54debug mode activated in a production system because it will allow users to53debug flag enables or disables the interactive debugger. *Never leave54debug mode activated in a production system*, because it will allow users to55execute code on the server!5657We also add a method to easily connect to the database specified. That58can be used to open a connection on request and also from the interactive
32 unmodified lines
modified:docs/quickstart.rst+16 added
824 unmodified lines
825can do it like this::826827 from werkzeug.contrib.fixers import LighttpdCGIRootFix828 app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)829830Deploying to a Web Server831-------------------------832833If you want to make your Flask app available to the Internet at large, `Heroku834<http://www.heroku.com>`_ is very easy to set up and will run small Flask835applications for free. `Check out their tutorial on how to deploy Flask apps on836their service <http://devcenter.heroku.com/articles/python>`_.837838There are a number of other websites that will host your Flask app and make it839easy for you to do so.840841- `Deploying Flask on ep.io <https://www.ep.io/docs/quickstart/flask/>`_842- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_843- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_844- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_