sparkmicro / Ki-nTree

Fast part creation for KiCad and InvenTree
GNU General Public License v3.0
171 stars 31 forks source link

Official way to run the app as a web server #243

Open LukeARESYS opened 1 week ago

LukeARESYS commented 1 week ago

Do you have a recommended method for running the KinTree app as a web server? We would like to have this functionality to be able to run this plugin on the same server where we're hosting Inventree, in this way we can ensure every user can access a correctly configured KinTree instance.

I've tried following the official Flet self hosting guide and I had mixed results: for various reasons I had to install KinTree on three different machines and the same setup worked on two machines only, but making it work was kind of a hassle.

I've installed kintree as sudo using pip, I succesfully setup nginx as described in the flet guide and I've created a systemd unit file like this:

[Unit]
Description=Kintree
After=network.target

[Service]
User=xxx
Group=xxx
Environment="FLET_SERVER_PORT=6001"
Environment="FLET_FORCE_WEB_SERVER=true"
Environment="FLET_WEB_APP_PATH=/kintree"
ExecStart=kintree

[Install]
WantedBy=multi-user.target

I then had to modify the kintree_gui.py file by changing def main(view='flet_app'): to def main(view='browser'):.

This is just a rough description of the steps I've followed just to give you an idea. Do you think these steps are recommended or do you suggest an alternative method?

If you need a more precise step-by-step description of the issues I've encountered I could try installing kintree again on a fresh machine.

NightSkySK commented 5 days ago

It would be awesome if self-hosting Kintree would be possible. I would go into this solution once it is supported. I use Kintree by myself, but I use a few computers to work with Kintree, so my short-term solution was setting config files on a mapped network drive. Each instance uses the same configuration, however self-hosting instance would be a much better solution.

eeintech commented 5 days ago

Hello there, thank you for your interest in Ki-nTree 😃

Yes it is possible to run the app in the browser but I am not sure about self-hosting it. The main problem with running it as webapp is KiCad file access. No webapp is allowed to access local files, for security reasons (which is why in the first place I designed it as a desktop app, Flet revamp came with version v1 and webapp possibility with it). If you do not use KiCad, then I don't see why not but I do not have the know-how at this time and very limited bandwidth to dig into it, sorry for the bad news.

However I am open to hear any solution you may find and, if not too much trouble, add it as a feature and/or in the documentation 😃