-
-
Notifications
You must be signed in to change notification settings - Fork 328
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
This is what I have tried so far and they worked.
Deploy for production
GCP (Google Cloud Platform)
-
reactpy with flask backend
See rflask -
reactpy with fastapi backend
See gcp-reactpy-fastapi
Replies: 7 comments 7 replies
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks I will try that.
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
Right, I got "failed: Error during WebSocket handshake"
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
The interactive examples in the docs are backed by Heroku:
Beta Was this translation helpful? Give feedback.
All reactions
-
I tried GCP, fastapi worked, but reactpy on fastapi backend did not work.
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
This is what I have tried so far and they worked.
Deploy for production
GCP (Google Cloud Platform)
- reactpy with flask backend
See rflask - reactpy with fastapi backend
See gcp-reactpy-fastapi
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for looking into this!
If you have time, it would be great if you could write tutorial(s) in GitHub Discussions "share" category!
Beta Was this translation helpful? Give feedback.
All reactions
-
I will write one day.
Beta Was this translation helpful? Give feedback.
All reactions
-
I also found you can deploy reactpy using a docker image. It works for platforms that don't support websockets.
Beta Was this translation helpful? Give feedback.