Skip to content
Myr

add heroku/deploy options to quickstart, and add more clear links in tutorial setup.

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

authored by Kevin Burke · committed by Kevin Burke · parent 7ed3cba · Browse files · 2 files+46 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+46 added−10 removed

  • other:+46 added−10 removed

2 files+46 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+36 added
824 unmodified lines
825can do it like this::826827 from werkzeug.contrib.fixers import LighttpdCGIRootFix828 app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)829830Share your Local Server with a Friend831-------------------------------------832833`Localtunnel <http://progrium.com/localtunnel/>`_ is a neat tool you can use to834quickly share your local Flask server to a friend.835836To install Localtunnel, open a terminal and run the following command::837838 sudo gem install localtunnel839840Then, with Flask running at ``http://localhost:5000``, open a new Terminal window841and type::842843 localtunnel 5000844 Port 5000 is now publicly accessible from http://54xy.localtunnel.com ...845846*(Get a* ``gem: command not found`` *error? Download RubyGems*847`here <http://rubygems.org/pages/download>`_ *.)*848849If you load the URL given in the localtunnel output in your browser, you850should see your Flask app. It's actually being loaded from your own computer!851852Deploying to a Web Server853-------------------------854855`Heroku <http://www.heroku.com>`_ offers a free web platform to host your856Flask app, and is the easiest way for you to put your Flask app online.857They have excellent instructions on how to deploy your Flask app `here858<http://devcenter.heroku.com/articles/python>`_.859860Other resources for deploying Flask apps:861862- `Deploying Flask on ep.io <https://www.ep.io/docs/quickstart/flask/>`_863- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_864- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_