Described HTTP methods
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent df929c6 · Browse files · 1 file·+57 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+57 added−0 removed
- other:+57 added−0 removed
Provenance
- Commit
8171da8- Tree
791345c- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
df929c6
1 file changed+57 added−0 removed
modified:docs/quickstart.rst+57 added
159 unmodified lines160 explained below. It basically tells flask to think we are handling a161 request even though we are not, we are in an interactive Python shell.162 Have a look at the explanation below. :ref:`context-locals`).163 164+Why would you want to build URLs instead of hardcoding them in your165+templates? There are three good reasons for this:166 167+1. reversing is often more descriptive than hardcoding the URLs. Also and168+ more importantly you can change URLs in one go without having to change169+ the URLs all over the place.170+2. URL building will handle escaping of special characters and unicode171+ data transparently for you, you don't have to deal with that.172+3. If your application is placed outside the URL root (so say in173+ ``/myapplication`` instead of ``/``), :func:`~flask.url_for` will174+ handle that properly for you.175+176+177 HTTP Methods178 ````````````179 180 HTTP knows different methods to access URLs. By default a route only12 unmodified lines193 don't have to deal with that. It will also make sure that ``HEAD``194 requests are handled like the RFC demands, so you can completely ignore195 that part of the HTTP specification.196 197+You have no idea what an HTTP method is? Worry not, here quick198+introduction in HTTP methods and why they matter:199+200+The HTTP method (also often called "the verb") tells the server what the201+clients wants to *do* with the requested page. The following methods are202+very common:203+204+`GET`205+ The Browser tells the server: just *get* me the information stored on206+ that page and send them to me. This is probably the most common207+ method.208+209+`HEAD`210+ The Browser tells the server: get me the information, but I am only211+ interested in the *headers*, not the content of the page. An212+ application is supposed to handle that as if a `GET` request was213+ received but not deliver the actual contents. In Flask you don't have214+ to deal with that at all, the underlying Werkzeug library handles that215+ for you.216+217+`POST`218+ The browser tells the server that it wants to *post* some new219+ information to that URL and that the server must ensure the data is220+ stored and only stored once.221+222+`PUT`223+ Similar to `POST` but the server might trigger the store procedure224+ multiple times by overwriting the old values more than once. Now you225+ might be asking why this is any useful, but there are some good226+ reasons to do that. Consider the connection is lost during227+ transmission, in that situation a system between the browser and the228+ server might sent the request safely a second time without breaking229+ things. With `POST` that would not be possible because it might only230+ be triggered once.231+232+`DELETE`233+ Remove the information that the given location.234+235+Now the interesting part is that in HTML4 and XHTML1, the only methods a236+form might submit to the server are `GET` and `POST`. But with JavaScript237+and future HTML standards you can use other methods as well. Furthermore238+HTTP became quite popular lately and there are more things than browsers239+that are speaking HTTP. (Your revision control system for instance might240+speak HTTP)241+242 Static Files243 ------------244 245 Dynamic web applications need static files as well. That's usually where342 unmodified lines