Python client for Hypernova, https://github.com/airbnb/hypernova
Project description
# hypernova-python
> A Python client for the Hypernova service
## Getting Started
Install the python client from pypi
```sh
pip install hypernova-python
```
Once you have the client installed and an instance of the Hypernova service running, you can making requests is easy.
### Example
```python
import hypernova
renderer = hypernova.Renderer('http://localhost')
html = renderer.render({'MyComponent.js': {'name': 'Foo'}})
```
## Configuration
You can pass configuration options to `Renderer` at initialization.
* `url`: The address of the Hypernova service is listening, including port if necessary
* `plugins`: A list of plugins to use
* `timeout`: Number of seconds to wait for a response from the Hypernova service
* `headers`: Dictionary of HTTP headers to override the default. You will want to include `'Content-Type': 'application/json'`
## Plugins
You can implement custom events and alter requests through the [Plugin Lifecycle](https://github.com/airbnb/hypernova-node/blob/master/README.md#plugin-lifecycle-api). All lifecycle methods are optional.
### Example
```python
import hypernova
import random
class MyPlugin(object):
def prepare_request(self, current_jobs, original_jobs):
job = current_jobs.get('MyComponent.js')
job.update({'random_int_for_reasons': random.randint(0, 100))
return current_jobs
renderer = hypernova.Renderer('http://localhost', [MyPlugin()])
```
> A Python client for the Hypernova service
## Getting Started
Install the python client from pypi
```sh
pip install hypernova-python
```
Once you have the client installed and an instance of the Hypernova service running, you can making requests is easy.
### Example
```python
import hypernova
renderer = hypernova.Renderer('http://localhost')
html = renderer.render({'MyComponent.js': {'name': 'Foo'}})
```
## Configuration
You can pass configuration options to `Renderer` at initialization.
* `url`: The address of the Hypernova service is listening, including port if necessary
* `plugins`: A list of plugins to use
* `timeout`: Number of seconds to wait for a response from the Hypernova service
* `headers`: Dictionary of HTTP headers to override the default. You will want to include `'Content-Type': 'application/json'`
## Plugins
You can implement custom events and alter requests through the [Plugin Lifecycle](https://github.com/airbnb/hypernova-node/blob/master/README.md#plugin-lifecycle-api). All lifecycle methods are optional.
### Example
```python
import hypernova
import random
class MyPlugin(object):
def prepare_request(self, current_jobs, original_jobs):
job = current_jobs.get('MyComponent.js')
job.update({'random_int_for_reasons': random.randint(0, 100))
return current_jobs
renderer = hypernova.Renderer('http://localhost', [MyPlugin()])
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hypernova-0.0.1.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for hypernova-0.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf02367ef690193ba8d04899b26329981c57627883c0dc992a01454d186e6307 |
|
MD5 | d5e0ce6cdf254062c5c9c870afb8baf1 |
|
BLAKE2b-256 | b9023d568a8b22ff8591dc1ef88b2eb87e13761a016074146c7e01c7d01aa7d2 |