docs: ``.html``, ``.py``
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by defuz · committed by defuz · parent d4b9b98 · Browse files · 8 files·+16 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+16 added−16 removed
- other:+16 added−16 removed
Provenance
- Commit
d338dc8- Tree
3c61a02- Author
defuz <defuz.net@gmail.com>- Committer
defuz <defuz.net@gmail.com>- Parent
d4b9b98
8 files changed+16 added−16 removed
modified:docs/deploying/cgi.rst+4 added-4 removed
22 unmodified lines23 Creating a `.cgi` file24 ----------------------25 26 First you need to create the CGI application file. Let's call it27-`yourapplication.cgi`::27+:file:`yourapplication.cgi`::28 29 #!/usr/bin/python30 from wsgiref.handlers import CGIHandler31 from yourapplication import app3 unmodified lines35 Server Setup36 ------------37 38 Usually there are two ways to configure the server. Either just copy the39-`.cgi` into a `cgi-bin` (and use `mod_rewrite` or something similar to39+``.cgi`` into a :file:`cgi-bin` (and use `mod_rewrite` or something similar to40 rewrite the URL) or let the server point to the file directly.41 42 In Apache for example you can put something like this into the config:43 1 unmodified line45 46 ScriptAlias /app /path/to/the/application.cgi47 48 On shared webhosting, though, you might not have access to your Apache config.49-In this case, a file called `.htaccess`, sitting in the public directory you want50-your app to be available, works too but the `ScriptAlias` directive won't49+In this case, a file called ``.htaccess``, sitting in the public directory you want50+your app to be available, works too but the ``ScriptAlias`` directive won't51 work in that case:52 53 .. sourcecode:: apache54 7 unmodified linesmodified:docs/deploying/mod_wsgi.rst+5 added-5 removed
50 unmodified lines51 52 Creating a `.wsgi` file53 -----------------------54 55-To run your application you need a `yourapplication.wsgi` file. This file55+To run your application you need a :file:`yourapplication.wsgi` file. This file56 contains the code `mod_wsgi` is executing on startup to get the application57 object. The object called `application` in that file is then used as58 application.59 9 unmodified lines69 the libraries that are in use are on the python load path. If you don't70 want to install it system wide consider using a `virtual python`_71 instance. Keep in mind that you will have to actually install your72 application into the virtualenv as well. Alternatively there is the73-option to just patch the path in the `.wsgi` file before the import::73+option to just patch the path in the ``.wsgi`` file before the import::74 75 import sys76 sys.path.insert(0, '/path/to/the/application')77 92 unmodified lines170 Support for Automatic Reloading171 -------------------------------172 173 To help deployment tools you can activate support for automatic174-reloading. Whenever something changes the `.wsgi` file, `mod_wsgi` will174+reloading. Whenever something changes the ``.wsgi`` file, `mod_wsgi` will175 reload all the daemon processes for us.176 177 For that, just add the following directive to your `Directory` section:178 6 unmodified lines185 186 Virtual environments have the advantage that they never install the187 required dependencies system wide so you have a better control over what188 is used where. If you want to use a virtual environment with mod_wsgi189-you have to modify your `.wsgi` file slightly.189+you have to modify your ``.wsgi`` file slightly.190 191-Add the following lines to the top of your `.wsgi` file::191+Add the following lines to the top of your ``.wsgi`` file::192 193 activate_this = '/path/to/env/bin/activate_this.py'194 execfile(activate_this, dict(__file__=activate_this))195 2 unmodified linesmodified:docs/patterns/fabric.rst+2 added-2 removed
84 unmodified lines85 86 However this requires that our server already has the87 :file:`/var/www/yourapplication` folder created and88 :file:`/var/www/yourapplication/env` to be a virtual environment. Furthermore89-are we not creating the configuration or `.wsgi` file on the server. So89+are we not creating the configuration or ``.wsgi`` file on the server. So90 how do we bootstrap a new server into our infrastructure?91 92 This now depends on the number of servers we want to set up. If we just93 have one application server (which the majority of applications will15 unmodified lines109 2. Upload a new :file:`application.wsgi` file to the server and the110 configuration file for the application (eg: :file:`application.cfg`)111 112 3. Create a new Apache config for ``yourapplication`` and activate it.113- Make sure to activate watching for changes of the `.wsgi` file so113+ Make sure to activate watching for changes of the ``.wsgi`` file so114 that we can automatically reload the application by touching it.115 (See :ref:`mod_wsgi-deployment` for more information)116 117 So now the question is, where do the :file:`application.wsgi` and79 unmodified linesmodified:docs/patterns/fileuploads.rst+1 added-1 removed
41 unmodified lines42 Why do we limit the extensions that are allowed? You probably don't want43 your users to be able to upload everything there if the server is directly44 sending out the data to the client. That way you can make sure that users45 are not able to upload HTML files that would cause XSS problems (see46-:ref:`xss`). Also make sure to disallow `.php` files if the server46+:ref:`xss`). Also make sure to disallow ``.php`` files if the server47 executes them, but who has PHP installed on his server, right? :)48 49 Next the functions that check if an extension is valid and that uploads50 the file and redirects the user to the URL for the uploaded file::140 unmodified linesmodified:docs/patterns/packages.rst+1 added-1 removed
21 unmodified lines22 23 To convert that into a larger one, just create a new folder24 :file:`yourapplication` inside the existing one and move everything below it.25 Then rename :file:`yourapplication.py` to :file:`__init__.py`. (Make sure to delete26-all `.pyc` files first, otherwise things would most likely break)26+all ``.pyc`` files first, otherwise things would most likely break)27 28 You should then end up with something like that::29 30 /yourapplication85 unmodified linesmodified:docs/tutorial/setup.rst+1 added-1 removed
6 unmodified lines7 Let's call it flaskr.py. We will place this file inside the flaskr folder.8 We will begin by adding the imports we need and by adding the config9 section. For small applications, it is possible to drop the configuration10 directly into the module, and this is what we will be doing here. However11-a cleaner solution would be to create a separate `.ini` or `.py` file and11+a cleaner solution would be to create a separate ``.ini`` or ``.py`` file and12 load that or import the values from there.13 14 First we add the imports in :file:`flaskr.py`::15 98 unmodified linesmodified:flask/app.py+1 added-1 removed
69 unmodified lines70 71 The name of the package is used to resolve resources from inside the72 package or the folder the module is contained in depending on if the73 package parameter resolves to an actual python package (a folder with74- an :file:`__init__.py` file inside) or a standard module (just a `.py` file).74+ an :file:`__init__.py` file inside) or a standard module (just a ``.py`` file).75 76 For more information about resource loading, see :func:`open_resource`.77 78 Usually you create a :class:`Flask` instance in your main module or1831 unmodified linesmodified:flask/helpers.py+1 added-1 removed
885 unmodified lines886 /templates887 /layout.html888 /index.html889 890- If you want to open the `schema.sql` file you would do the890+ If you want to open the :file:`schema.sql` file you would do the891 following::892 893 with app.open_resource('schema.sql') as f:894 contents = f.read()9 unmodified lines