Is it possible to include a RESTful server in a Desktop app?

Does anyone remember FileMaker Pro? Like freedom, it was both wonderful and horrible at the same time… but one of the things that made it wonderful was the idea that you could use it to create a database on your computer and share it with other computers running FMP on the same network. It could be a list of employee phone numbers or the latest pricing from distribution… you could simply turn on sharing and others could connect to your data. Likewise, you could look out on the network and connect to any FMP database that was being shared.

I’m pretty sure that I know the answer to this question but basically, I would like to know if it’s possible to run a RESTful API to serve a database using the Desktop version of Xojo. Ideally, I’d like to bake the server right into the same app that acts as the client.

Seeing that I can’t seem to fine HandleSpecialURL anywhere in Desktop, I have a feeling that the answer is to create two apps, a Web app to be the REST server and a Desktop app to be the client.

HandleSpecialURL doesn’t do much special. You need a server socket, you need to define a grammar and parse the url.

It’s possible, but you would need a helper app acting as server side-by-side to your desktop app. By saying that I have to add that this is a bad application design. You’re setting up a local service, which needs an open port and makes your client computer vulnerable. You have to decide how to control this service to prevent running when your desktop app has stopped intendedly or unintendedly. It increases the chance of recieving annoying warning messages by firewalls and anti-malware software. If you want to commuicate via Webservices, then you must do this via TLS encrypted communication (and in best case with support of other technologies like HSTS etc.) otherwise all your data is transfered in cleartext. Any other desktop app (or in worst case remote software e.g. proxy) could read/capture/manipulate your desktop-client communication and would threaten the integrity of your data.

Bottomline: Don’t do this.

@Kristin Green : if you need a highly scalable, secure etc solution then Tomas Jakobs is of course correct. If you need a simple, local network solution then you can use a simpler approach.

e.g. communicating with an local SQLite DB or local textfiles directly.

The easiest way is probably to create two apps as you suggest, but then communicate between them with Xojo’s built in IPC classes to keep things a bit faster and less race condition prone than using your own local files: https://documentation.xojo.com/api/networking/ipcsocket.html

Alternatively, you could use the Aloe library (https://aloe.zone/) to provide a server directly from your desktop app. It would need to be run on it’s own thread to not interrupt processing of GUI events.

If you do make a web service, use standard security practices and it’s perfectly safe. Lots of very successful software does this, but you have to be careful.

Alternatives:
If you just want your own apps to communicate locally, just stick with IPC.

If you need apps across multiple machines to communicate you may also want to think of using something like CubeSQL (cubeSQL: A fully featured and high performance relational database management system built on top of the sqlite database engine) as the central server – it handles encryption and authentication already so it’s a good choice if you just need to share data (maybe even some custom logic via its plugin system).

@ Isaac : Aloe looks amazing! Thanks for that! Running this in it’s own thread sounds exactly like what I was looking for.

Thanks to all who replied. :slight_smile: