File: post_body_example.py

package info (click to toggle)
python-hug 2.6.0-2.4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,072 kB
  • sloc: python: 8,938; sh: 99; makefile: 17
file content (17 lines) | stat: -rw-r--r-- 462 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""A simple post reading server example.

To test run this server with `hug -f post_body_example`
then run the following from ipython:
    import requests

    requests.post('http://localhost:8000/post_here', json={'one': 'two'}).json()

    This should return back the json data that you posted
"""
import hug


@hug.post()
def post_here(body):
    """This example shows how to read in post data w/ hug outside of its automatic param parsing"""
    return body