Skip to content

Commit

Permalink
Merge pull request #740 from akaihola/multiple_files-example-document…
Browse files Browse the repository at this point in the history
…ation

Added documentation for the `multiple_files` example
  • Loading branch information
timothycrosley committed Mar 19, 2019
2 parents 78afab0 + ea4db21 commit b615fdc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions ACKNOWLEDGEMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Documenters
- Amanda Crosley (@waddlelikeaduck)
- Chelsea Dole (@chelseadole)
- Joshua Crowgey (@jcrowgey)
- Antti Kaihola (@akaihola)

--------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Ideally, within a virtual environment.
Changelog
=========

### 2.4.4 - TBD
- Documented the `multiple_files` example

### 2.4.3 [hotfix] - March 17, 2019
- Fix issue #737 - latest hug release breaks meinheld worker setup

Expand Down
9 changes: 9 additions & 0 deletions examples/multiple_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Splitting the API into multiple files

Example of an API defined in multiple Python modules and combined together
using the `extend_api()` helper.

Run with `hug -f api.py`. There are three API endpoints:
- `http://localhost:8000/``say_hi()` from `api.py`
- `http://localhost:8000/part1``part1()` from `part_1.py`
- `http://localhost:8000/part2``part2()` from `part_2.py`
7 changes: 7 additions & 0 deletions examples/multiple_files/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@

@hug.get('/')
def say_hi():
"""This view will be at the path ``/``"""
return "Hi from root"


@hug.extend_api()
def with_other_apis():
"""Join API endpoints from two other modules
These will be at ``/part1`` and ``/part2``, the paths being automatically
generated from function names.
"""
return [part_1, part_2]
1 change: 1 addition & 0 deletions examples/multiple_files/part_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

@hug.get()
def part1():
"""This view will be at the path ``/part1``"""
return 'part1'
1 change: 1 addition & 0 deletions examples/multiple_files/part_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

@hug.get()
def part2():
"""This view will be at the path ``/part2``"""
return 'Part 2'

0 comments on commit b615fdc

Please sign in to comment.