Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions examples/frontend-rendering-with-webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ As mentioned in the ***Using React on the front-end*** section, [Webpack](https:

In this example, the basic_rendering example is modified to submit the Comment Form through ajax and update the Comment List by fetching the updated comments and rendering the application with new props.

### Usage
Install the dependencies

```
pip install -r requirements.txt
npm install
```

Start the render server

### Usage in development
Extending the explanation in the [README](https://github.com/markfinger/python-react/blob/master/README.md#usage-in-development) section of the repo, restarting the render server everytime a change is made in the `.jsx` files can be avoided, by running:
```
node render_server.js
npm run watch
```

Start the python server

alongside the python dev server:
```
python example.py
```
The forever utility check for changes and restarts the `render_server` accordingly.

And visit [http://127.0.0.1:5000](http://127.0.0.1:5000)




### Usage in production
Node server can be hosted in multiple ways. Either in the same box as flask server, or elsewhere. One way is to run it as a supervisord job on the same server. The React app needs to bundled as production ready before deploying the python server. This bundle is included in the `base` template for the app to render again on the client side. For bundling, run:
```
npm run postinstall
```
3 changes: 2 additions & 1 deletion examples/frontend-rendering-with-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"private": true,
"scripts": {
"watch": "webpack --watch & forever --watch --watchDirectory ./static/js/src ./render_server.js"
"watch": "webpack --watch & forever --watch --watchDirectory ./static/js/src ./render_server.js",
"postinstall": "webpack -p"
},
"dependencies": {
"babel-core": "^6.1.20",
Expand Down