-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed docs with expected curl headers and output
- Loading branch information
1 parent
4fb1116
commit 4bf1107
Showing
6 changed files
with
163 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
Usage Examples | ||
============== | ||
|
||
A few examples on how to use :mod:`mimerender` with the different supported frameworks. | ||
Content-Type selection | ||
---------------------- | ||
|
||
A few examples on how to use :mod:`mimerender` with the different supported frameworks. Any of these will behave this way: | ||
|
||
.. literalinclude:: ../examples/bottle_example.py | ||
:language: bash | ||
:lines: 3-25 | ||
|
||
Bottle | ||
------ | ||
++++++ | ||
|
||
.. literalinclude:: ../examples/bottle_example.py | ||
:lines: 8- | ||
:lines: 28- | ||
|
||
Flask | ||
----- | ||
+++++ | ||
|
||
.. literalinclude:: ../examples/flask_example.py | ||
:lines: 8- | ||
:lines: 28- | ||
|
||
Webapp2 | ||
------- | ||
+++++++ | ||
|
||
.. literalinclude:: ../examples/webapp2_example.py | ||
:lines: 8- | ||
:lines: 28- | ||
|
||
web.py | ||
------ | ||
++++++ | ||
|
||
.. literalinclude:: ../examples/webpy_example.py | ||
:lines: 8- | ||
:lines: 28- | ||
|
||
Exception Mapping | ||
----------------- | ||
Content-Type selection plus Exception Mapping | ||
--------------------------------------------- | ||
|
||
:mod:`mimerender` provides a helper decorator for mapping exceptions to HTTP Status Codes. | ||
|
||
.. literalinclude:: ../examples/exception_mapping_example.py | ||
:lines: 11- | ||
:lines: 47- | ||
|
||
:mod:`mimerender` will take care of mapping :class:`ValueError` and :class:`NotFound` to the specified HTTP status codes, and it will serialize the exception with an acceptable Content-Type: | ||
|
||
.. literalinclude:: ../examples/exception_mapping_example.py | ||
:language: bash | ||
:lines: 3-45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters