Merge branch 'flask_deployment_docs'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Conflicts: docs/quickstart.rst
authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 86525d9, 5c6d789 · Browse files · 2 files·+47 added−49 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+47 added−49 removed
- other:+47 added−49 removed
Provenance
- Commit
f166894- Tree
6210e82- Author
Markus Unterwaditzer <markus@unterwaditzer.net>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent 1
86525d9- Parent 2
5c6d789
2 files changed+47 added−49 removed
modified:docs/deploying/index.rst+22 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+While lightweight and easy to use, **Flask's built-in server is not suitable7+for production** as it doesn't scale well and by default serves only one8+request at a time. Some of the options available for properly running Flask in9+production are documented here.10 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.11+If you want to deploy your Flask application to a WSGI server not listed here,12+look up the server documentation about how to use a WSGI app with it. Just13+remember that your :class:`Flask` application object is the actual WSGI14+application.15 16-For hosted options to get up and running quickly, see17-:ref:`quickstart_deployment` in the Quickstart.16 17+Hosted options18+--------------19+20+- `Deploying Flask on Heroku <https://devcenter.heroku.com/articles/getting-started-with-python>`_21+- `Deploying WSGI on dotCloud <http://docs.dotcloud.com/services/python/>`_22+ with `Flask-specific notes <http://flask.pocoo.org/snippets/48/>`_23+- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_24+- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_25+- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_26+27+28+Self-hosted options29+-------------------30+31 .. toctree::32 :maxdepth: 233 34 mod_wsgi4 unmodified linesmodified:docs/quickstart.rst+25 added-39 removed
18 unmodified lines19 @app.route('/')20 def hello_world():21 return 'Hello World!'22 23-Just save it as :file:`hello.py` (or something similar) and run it with your Python24-interpreter. Make sure to not call your application :file:`flask.py` because this25-would conflict with Flask itself.26-27-To run the application you can either use the :command:`flask` command or28-python's :option:`-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-23 So what did that code do?24 25 1. First we imported the :class:`~flask.Flask` class. An instance of this26 class will be our WSGI application.8 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 :file:`hello.py` (or something similar) and run it with your Python41+interpreter. Make sure to not call your application :file:`flask.py` because this42+would conflict with Flask itself.43 44+To run the application you can either use the :command:`flask` command or45+python's :option:`-m` switch with Flask::46+47+ $ flask -a hello run48+ * Running on http://127.0.0.1:5000/49+50+or alternatively::51+52+ $ python -m flask -a hello run53+ * Running on http://127.0.0.1:5000/54+55+This launches a very simple builtin server, which is good enough for testing56+but probably not what you want to use in production. For deployment options see57+:ref:`deployment`.58+59+Now head over to `http://127.0.0.1:5000/ <http://127.0.0.1:5000/>`_, and you60+should see your hello world greeting.61+62 .. _public-server:63 64 .. admonition:: Externally Visible Server65 9 unmodified lines75 flask -a hello run --host=0.0.0.076 77 This tells your operating system to listen on all public IPs.78 79+80 What to do if the Server does not Start81 ---------------------------------------82 83 In case the ``python -m flask`` fails or :command:`flask` does not exist,775 unmodified lines859 :class:`~logging.Logger`, so head over to the official `logging860 documentation <https://docs.python.org/library/logging.html>`_ for more861 information.862 863+Read more on :ref:`application-errors`.864+865 Hooking in WSGI Middlewares866 ---------------------------867 868 If you want to add a WSGI middleware to your application you can wrap the3 unmodified lines872 873 from werkzeug.contrib.fixers import LighttpdCGIRootFix874 app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)875 873-.. _quickstart_deployment:874-876 Deploying to a Web Server877 -------------------------878 878-Ready to deploy your new Flask app? To wrap up the quickstart, you can879-immediately deploy to a hosted platform, all of which offer a free plan for880-small projects:881-882-- `Deploying Flask on Heroku <https://devcenter.heroku.com/articles/getting-started-with-python>`_883-- `Deploying WSGI on dotCloud <http://docs.dotcloud.com/services/python/>`_884- with `Flask-specific notes <http://flask.pocoo.org/snippets/48/>`_885-886-Other places where you can host your Flask app:887-888-- `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_889-- `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_890-- `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_891-892-If you manage your own hosts and would like to host yourself, see the chapter893-on :ref:`deployment`.879+Ready to deploy your new Flask app? Go to :ref:`deployment`.