Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nitely/python-react-v8
:star: Render React.js views server-side
https://github.com/nitely/python-react-v8
python react server-rendered v8 v8-cffi
Last synced: about 2 months ago
JSON representation
:star: Render React.js views server-side
- Host: GitHub
- URL: https://github.com/nitely/python-react-v8
- Owner: nitely
- License: mit
- Created: 2016-05-11T18:14:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-22T23:39:39.000Z (about 5 years ago)
- Last Synced: 2024-10-12T07:14:16.830Z (2 months ago)
- Topics: python, react, server-rendered, v8, v8-cffi
- Language: Python
- Homepage: http://python-react-v8.readthedocs.io
- Size: 64.5 KB
- Stars: 81
- Watchers: 4
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Python-React-V8
[![Build Status](https://img.shields.io/travis/nitely/python-react-v8.svg?style=flat-square)](https://travis-ci.org/nitely/python-react-v8)
[![Coverage Status](https://img.shields.io/coveralls/nitely/python-react-v8.svg?style=flat-square)](https://coveralls.io/r/nitely/python-react-v8)
[![pypi](https://img.shields.io/pypi/v/python-react-v8.svg?style=flat-square)](https://pypi.python.org/pypi/python-react-v8)
[![licence](https://img.shields.io/pypi/l/python-react-v8.svg?style=flat-square)](https://raw.githubusercontent.com/nitely/python-react-v8/master/LICENSE)Thin wrapper around [v8-cffi](https://github.com/nitely/v8-cffi) to render React views server-side.
## Compatibility
[What v8-cffi supports](https://github.com/nitely/v8-cffi#compatibility)
## Install
```
$ pip install python-react-v8
```## Usage
```python
import reactfrom my_web_framework import render, orm, runserver
def index(request):
"""A naive implementation for a fake web-framework"""
data = orm.query().only('name', 'age', 'location')
react_ = react.React({
'url': request.get_full_url(),
'data': data})
context = {
'content': react_.render(),
'data': react_.to_json(data)}return render('index.html', context)
if __name__ == '__main__':
react.set_up() # Initialize V8 machinery
react.utils.load_libs(['./bundle.js'])
runserver(index)
```Read the [docs](http://python-react-v8.readthedocs.org/en/latest/).
## Examples
* [Flux](https://github.com/nitely/python-react-v8/tree/master/examples/flux)
* [Simple](https://github.com/nitely/python-react-v8/tree/master/examples/simple)## Build examples
```
$ make build-examples
```## Tests
```
$ make test
```## License
MIT