Home » Community » Coffee corner » C++ and HTML+Javascript
|
Re: C++ and HTML+Javascript [message #60532 is a reply to message #60531] |
Wed, 03 April 2024 04:43   |
zsolt
Messages: 702 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Hi Luigi,
our invoicing app's website works in a similar way.
The backend is U++ (HTTP, JSON), the frontend is vanilla Javascript + Bootstrap CSS + HTML.
My next project will be the JS frontend for the invoicing app.
The U++ backend is in production already. The desktop app uses it currently as an HTTPS client.
Much faster and more scalable than using an open PostgreSQL port.
U++ is absolute usable for this type of development.
[Updated on: Wed, 03 April 2024 04:44] Report message to a moderator
|
|
|
|
Re: C++ and HTML+Javascript [message #60534 is a reply to message #60533] |
Wed, 03 April 2024 22:22   |
zsolt
Messages: 702 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Hi Luigi,
it is not skylark.
It is a very simple single process multi threaded server.
It binds to a port, starts a fixed number of threads to serve the incoming requests and parses headers with HttpHeader class.
After that it finds out the endpoint from the URL.
There is a macro generated map with the registered endpoints and based on them, it calls a macro generated function, that parses the HTTP body into the struct, that is the argument of that specific endpoint method.
After that it calls that method within a server class with the deserialized argument.
I use Jsonize here.
Then the method does whatever it wants and returns an other struct.
Then the macro generated code serializes it to JSON and sends it back to the client.
So yes, the U++ client communicates with this remote U++ (HTTP + JSON) server.
On client side, the code is just calling the same methods with the jsonizeable structs and a macro generated code does the rest.
The invoicing software can also run with a local sqlite or postgresql database. For this case there are other macros, generating the same methods in a class, that calls the endpoint code directly as methods.
Implementing the server and client side code is very easy this way
You just have to write normal methods on server side and call the methods with the same name on client side. And the new Assist is helping you also.
There are some more complex things in it also. For example the exceptions thrown in the server code are propagated to the client side, so the error handling is quite simple as well.
There is a macro, generating the callable javascript functions also.
This "framework" is similar to the database framework of U++.
I run the server side U++ daemon behind Nginx on Linux.
[Updated on: Wed, 03 April 2024 22:27] Report message to a moderator
|
|
|
|
Re: C++ and HTML+Javascript [message #60539 is a reply to message #60536] |
Tue, 09 April 2024 23:49  |
zsolt
Messages: 702 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Hi Luigi,
Quote:If I have understood, then a desktop app can be built using U++, HTML, CSS and Javascript using a browser as renderer.
Yes, but my purpose is to run the JS GUI in a web browser.
Quote:I wish one day to see a "hello world" test case built with such tecnology.
I plan releasing the core of it. Currently the code is messy with a lot of different older experimental APIs and it is not separated from the app enough. After finishing the web based GUI, I think it will be evolved to a more general and cleaner state.
|
|
|
Goto Forum:
Current Time: Sun Apr 27 15:43:02 CEST 2025
Total time taken to generate the page: 0.06590 seconds
|