Skip to content

irdvl/starlette-react

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

starlette-react

Fork of a basic example of using a React application with Starlette.

This one works with the newer Starlette API and has some logic for pre-rendering the React components and serving them from Starlette server instead of running a separate node server to serve front end.

Setup

Backend

Requirements: Python 3.6+

  • Install starlette and uvicorn from the requirements file in the backend directory:

    pip install -r requirements.txt --upgrade

  • Run the application using uvicorn:

    make run / python backend/app.py serve

Uvicorn is the ASGI server used to run the application in this example, however other ASGI servers, such as Hypercorn and Daphne could be used as well.

Frontend

The React app was initially created using the create-react-app command.

  • Install the dependencies:

    cd frontend; yarn install

  • Run the server for local development:

    cd frontend; yarn start

  • Build front end assets to serve from the Python app:

    make build

Deploying

The app is configured to seamlessly run on https://render.com/. Make sure that front end assets are rendered in the branch you are deploying.

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.0%
  • HTML 21.0%
  • Python 16.8%
  • CSS 7.4%
  • Makefile 1.4%
  • Dockerfile 1.4%