This is a template for web-applications with Python 3 Flask, a React frontend, a separate Express web server and Webpack bundling.
The Flask application could just serve the React application directly. Serving the website from a Node.js Express server instead has several advantages such as server-side rendering and webpack hot-reloading.
First you will need to install the Node.js and Python dependencies.
npm i
virtualenv .venv && source .venv/bin/activate && pip install -r requirements.txt
Then you should use two separate terminals or bash jobs to run the web and API servers. Then visit http://localhost:8080
npm start web:dev
npm start api:dev
You may want to remove package-lock.json
from .gitignore
.
You must build the webpack bundle and transpile the server-side code for production use. We also highly recommend using a production-grade WSGI like Gunicorn for the Flask component.
npm run build
npm start web
gunicorn -w 4 application.api.main:app
Licensed under WTFPL