Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deploy #1098

Answered by fsmosca
zferdz asked this question in Question
Deploy #1098
Jul 12, 2023 · 7 comments · 7 replies
Discussion options

Is there any guide or even possible to deploy on:

  • GCP (Google Coud platform)
  • Netlify
  • Space
  • Github
  • Heroku
  • Others

I have already read this documentation.

Thanks.

You must be logged in to vote

This is what I have tried so far and they worked.

Deploy for production

GCP (Google Cloud Platform)

Replies: 7 comments 7 replies

Comment options

Deployment instructions are going to be based on your chosen backend.

For example, if you use the Flask or Django backend and want to deploy via Azure, a tutorial like this would describe the process:
https://learn.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app?tabs=flask%2Cwindows

You must be logged in to vote
1 reply
Comment options

Thanks I will try that.

Comment options

I did try the fastapi in deta-space (not a reactpy) from this guide. It worked.

Then I tried the reactpy sample code for fastapi or the code below.

main.py

from reactpy import component, html
from reactpy.backend.fastapi import configure
from fastapi import FastAPI # missing in official sample code.
@component
def HelloWorld():
 return html.h1("Hello, world!")
app = FastAPI()
configure(app, HelloWorld)

But I got nothing. There was no Hello, world! displayed.

The project myreactpy log in deta-space does not indicate any errors.

And this is my Spacefile for deta-space. Typical for fastapi use.

v: 0
micros:
 - name: myreactpy
 src: .
 engine: python3.9
 run: uvicorn main:app
You must be logged in to vote
3 replies
Comment options

Can you check your browser console logs? I'm willing to bet that a standard fast API configuration does not forward websockets.

ReactPy requires websockets to function.

Comment options

Right, I got "failed: Error during WebSocket handshake"

Comment options

Yep you'll need to figure out where exactly you need to enable WebSocket support. If the same ReactPy configuration works in a local environment, then it's likely some configuration on your hosting provider.

If you are using Nginx, that also needs to be configured for websockets.

Comment options

Deployment instructions are going to be based on your chosen backend.

For example, if you use the Flask or Django backend and want to deploy via Azure, a tutorial like this would describe the process: https://learn.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app?tabs=flask%2Cwindows

I can't register in azure at the moment.

I will try gcp instead as I already have an account on it.

You must be logged in to vote
0 replies
Comment options

The interactive examples in the docs are backed by Heroku:

You must be logged in to vote
0 replies
Comment options

I tried GCP, fastapi worked, but reactpy on fastapi backend did not work.

You must be logged in to vote
1 reply
Comment options

I suspect that this is the main reason for the issues on GCP. The GCP docs state:

WebSockets clients connecting to Cloud Run should handle reconnecting to the server if the request times out or the server disconnects. You can achieve this in browser-based clients by using libraries such as reconnecting-websocket or by handling "disconnect" events if you are using the SocketIO library.

It is likely that our reconnection logic is insufficient. The GCP docs suggest using the same reconnecting-websocket library I did in the issue.

Comment options

This is what I have tried so far and they worked.

Deploy for production

GCP (Google Cloud Platform)

You must be logged in to vote
2 replies
Comment options

Thanks for looking into this!

If you have time, it would be great if you could write tutorial(s) in GitHub Discussions "share" category!

Comment options

I will write one day.

Answer selected by Archmonger
Comment options

I also found you can deploy reactpy using a docker image. It works for platforms that don't support websockets.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /