Rewrite deployment docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent 0a7cc2b · Browse files · 2 files·+50 added−50 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+50 added−50 removed
- other:+50 added−50 removed
Provenance
- Commit
3d3b809- Tree
8d8fe74- Author
Markus Unterwaditzer <markus@unterwaditzer.net>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent
0a7cc2b
2 files changed+50 added−50 removed
modified:docs/deploying/index.rst+25 added-10 removed
1 unmodified line2 3 Deployment Options4 ==================5 6-Depending on what you have available there are multiple ways to run7-Flask applications. You can use the builtin server during development,8-but you should use a full deployment option for production applications.9-(Do not use the builtin development server in production.) Several10-options are available and documented here.6+Flask's builtin server is lightweight and easy to use, but it has multiple7+problems which you don't want to face in production. With default settings, it8+can handle only one request at a time, and even if you manage to circumvent9+this problem, it has too many scaling problems that would make it unsuitable10+for production. **Do not use the builtin development server in production**.11+Some of the options available for properly running Flask in production are12+documented here.13 12-If you have a different WSGI server look up the server documentation13-about how to use a WSGI app with it. Just remember that your14-:class:`Flask` application object is the actual WSGI application.14+If you want to deploy your Flask application to a WSGI server not listed here,15+look up the server documentation about how to use a WSGI app with it. Just16+remember that your :class:`Flask` application object is the actual WSGI17+application.18 16-For hosted options to get up and running quickly, see17-:ref:`quickstart_deployment` in the Quickstart.19 20+Hosted options21+--------------22+23+- `Deploying Flask on Heroku <https://devcenter.heroku.com/articles/getting-started-with-python>`_24+- `Deploying WSGI on dotCloud <http://docs.dotcloud.com/services/python/>`_25+ with `Flask-specific notes <http://flask.pocoo.org/snippets/48/>`_26+- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_27+- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_28+- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_29+30+31+Self-hosted options32+-------------------33+34 .. toctree::35 :maxdepth: 236 37 mod_wsgi4 unmodified linesmodified:docs/quickstart.rst+25 added-40 removed
18 unmodified lines19 @app.route('/')20 def hello_world():21 return 'Hello World!'22 23-Just save it as `hello.py` (or something similar) and run it with your Python24-interpreter. Make sure to not call your application `flask.py` because this25-would conflict with Flask itself.23+So what does that code do?24 27-To run the application you can either use the ``flask`` command or28-python's ``-m`` switch with Flask::29-30- $ flask -a hello run31- * Running on http://127.0.0.1:5000/32-33-or alternatively::34-35- $ python -m flask -a hello run36- * Running on http://127.0.0.1:5000/37-38-Now head over to `http://127.0.0.1:5000/ <http://127.0.0.1:5000/>`_, and you39-should see your hello world greeting.40-41-So what did that code do?42-25 1. First we imported the :class:`~flask.Flask` class. An instance of this26 class will be our WSGI application.27 2. Next we create an instance of this class. The first argument is the name of28 the application's module or package. If you are using a single module (as6 unmodified lines35 should trigger our function.36 4. The function is given a name which is also used to generate URLs for that37 particular function, and returns the message we want to display in the38 user's browser.57-5. Finally we use the Flask development server to run the local server58- with our application.39 60-To stop the server, hit control-C.40+Just save it as `hello.py` (or something similar). Make sure to not call your41+application `flask.py` because this would conflict with Flask itself.42 43+To run the application you can either use the ``flask`` command or44+python's ``-m`` switch with Flask::45+46+ $ flask -a hello run47+ * Running on http://127.0.0.1:5000/48+49+or alternatively::50+51+ $ python -m flask -a hello run52+ * Running on http://127.0.0.1:5000/53+54+This launches a very simple builtin server, which is good enough for testing55+but probably not what you want to use in production. For deployment options see56+:ref:`deployment`.57+58+Now head over to `http://127.0.0.1:5000/ <http://127.0.0.1:5000/>`_, and you59+should see your hello world greeting. To stop the server, hit control-C.60+61 .. _public-server:62 63 .. admonition:: Externally Visible Server64 9 unmodified lines74 flask -a hello run --host=0.0.0.075 76 This tells your operating system to listen on all public IPs.77 78+79 What to do if the Server does not Start80 ---------------------------------------81 82 In case the ``python -m flask`` fails or ``flask`` does not exist,774 unmodified lines857 :class:`~logging.Logger`, so head over to the official `logging858 documentation <https://docs.python.org/library/logging.html>`_ for more859 information.860 861+Read more on :ref:`errorhandling`.862+863 Hooking in WSGI Middlewares864 ---------------------------865 866 If you want to add a WSGI middleware to your application you can wrap the3 unmodified lines870 871 from werkzeug.contrib.fixers import LighttpdCGIRootFix872 app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)873 872-.. _quickstart_deployment:873-874 Deploying to a Web Server875 -------------------------876 877-Ready to deploy your new Flask app? To wrap up the quickstart, you can878-immediately deploy to a hosted platform, all of which offer a free plan for879-small projects:880-881-- `Deploying Flask on Heroku <https://devcenter.heroku.com/articles/getting-started-with-python>`_882-- `Deploying WSGI on dotCloud <http://docs.dotcloud.com/services/python/>`_883- with `Flask-specific notes <http://flask.pocoo.org/snippets/48/>`_884-885-Other places where you can host your Flask app:886-887-- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_888-- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_889-- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_890-891-If you manage your own hosts and would like to host yourself, see the chapter892-on :ref:`deployment`.877+Ready to deploy your new Flask app? Go to :ref:`deployment`.