Registry / web-framework / hug
library2.6.1pypypiunverified

Hug is a Python 3+ framework for developing REST APIs as simply as possible. It supports both synchronous and asynchronous endpoints, automatic input validation, and built-in interactive documentation. Current version is 2.6.1 (released August 2019). The project is in maintenance mode (no releases since 2019).

pip install hug
INSTALL
IMPORT
SIG · HUG
H
hug
web-frameworkpythonv2.6.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

API
from hug import API
hug.get/post/put/delete
import hug @hug.get('/path')
Functions are attributes of the hug module, not a submodule.
route decorator
from hug import route

Create a simple GET endpoint and serve it on default port 8000.

import hug @hug.get('/hello') def hello(name: str): return {'hello': name} if __name__ == '__main__': hug.API(__name__).http.serve()
hug --version
Debug
Known issues
breakingFalcon 2.0+ changes broke hug. Hug forces Falcon <2.0 by default. If you need newer Falcon, set `__hug__.future = True` before importing hug endpoints, but expect breakage.
fix
Pin falcon <2.0 or test with `__hug__.future = True`
affects: >=2.5.2
deprecatedPython 3.5 support dropped as of 2.5.1.
fix
Use Python >=3.6
affects: >=2.5.1
gotchaPOST requests broke in 2.5.0 (fixed in 2.5.1). Ensure you are on at least 2.5.1 if using POST.
fix
Upgrade to hug >=2.5.1
affects: 2.5.0 only
gotchaEmpty query params are not ignored on 2.5.0 (fixed in 2.5.1).
fix
Upgrade to hug >=2.5.1
affects: 2.5.0
Errors
Common errors & fixes
TypeError: 'NoneType' object is not callable
Using `hug.API(__name__).http.serve()` after upgrading Falcon without pinning.
fix
Pin falcon<2.0 or set `__hug__.future = True` before importing hug.
ImportError: cannot import name 'route' from 'hug'
Incorrect import path. 'route' is not a submodule.
fix
Use `import hug` and then `@hug.route('/path')` or `from hug import route` (direct import from hug package).
TypeError: a bytes-like object is required, not 'str'
Using Python 3 with Falcon < 2.0 but passing non-bytes body.
fix
Ensure your response handlers return strings or use `hug.output_format.json` properly.
Upgrade
Version history
2.6.1latest on PyPI · released Feb 6, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
hug — pip install hug · libregistry