TexteaInc / funix

Building web apps without manually creating widgets
http://funix.io
MIT License
89 stars 10 forks source link

One package and one command for both frontend and backend #56

Closed forrestbao closed 1 year ago

forrestbao commented 1 year ago

Just like in Streamlit or Gradio.

forrestbao commented 1 year ago

Can we set the frontend port to 80 by default instead of 3000? It will make the life of ordinary users easier. They don't know what port is and will be freaked when they see :[PORT] in the URL. Also, let the frontend app's URL be {hostname}/{function_name}? So the URL to ordinary people can be short.

Yazawazi commented 1 year ago

To be honest, the backend address is needed because our project is front- and back-end separated and you have to specify where the front-end is using the service from.

So the best path would be: {hostname}?backend={backend}&function={function_name}

forrestbao commented 1 year ago

To be honest, the backend address is needed because our project is front- and back-end separated and you have to specify where the front-end is using the service from.

Yes, the frontend needs to know the backend address is but passing the backend address in the URL of a frontend app is bad solution. It is too long and ugly.

Instead, the backend's URL, including port, should be passed to the frontend without the awareness or intervention of users.

The frontend app's URL in Gradio or Streamlit is as simple as hostname:port. Since they are open source, maybe you can take a look how they do it.

One solution is to start the backend server first. Then passing the backend URL as an argument when starting the frontend server, like

yarn start --backend localhost --backend-port 3000

Or use environment variables. Or use config files - backend writes to it and frontend reads.

Or let the frontend scan ports.

So the best path would be: {hostname}?backend={backend}&function={function_name}

Question mark ? is not good. User /.

Yazawazi commented 1 year ago

Done in: https://github.com/TexteaInc/funix/commit/a8fd3e7d5bed1c329c357b8aeff1d003d77246c0, https://github.com/TexteaInc/funix/commit/ff6d7b9a0c79514201e7176e116299528aff9497, https://github.com/TexteaInc/funix/commit/a603cbffac7d8c1c9bf4db9250f6cedd8686d2c8, https://github.com/TexteaInc/funix/commit/85b85f4600a121692a56573c02246055a8059428