webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.63k stars 157 forks source link

Issue with 'USE_ZLIB' #259

Closed gvanem closed 9 months ago

gvanem commented 9 months ago

I just discovered this cool project and built text-editor.exe using MSVC/clang-cl. And it worked just fine!

Now trying to build with -DUSE_ZLIB, I get an error from this missing file in src/civetweb/civetweb.c:

#if defined(USE_ZLIB)
#include "mod_zlib.inl"
#endif

I see in this Civetweb PR that it's merged into that project.
I'm not sure about the relationship between these 2 projects.

I fixed this by just D/L this "mod_zlib.inl" from Civetweb's repo. Perhaps it should be added here too? Or add Civetweb's repo to a .gitmodule?

hassandraga commented 9 months ago

ZLIB is marked as experimental in Civetweb, so we did not include it by default. But I guess it's a good idea to add the mod_zlib.inl into src/civetweb.

gvanem commented 9 months ago

Ok. And what about the others like openssl_dl.inl and the mod_lua*.inl stuff? I feel something like:

#if defined(WEBUI_TLS) || defined(USE_LUA)
#error "An unsupported feature was detected"
#endif

should be added to webui.c since it's rather hard to know what is supported in WebUI or not.

hassandraga commented 9 months ago

Seriously. Thank you @gvanem, for reporting this. While digging into what features WebUI integrated web server should have... while digging I found how much WebUI will be helpful if we can use it with an external powerful web server like NGINX or Apache, or someone like in your case where you want Civetweb to have a specific feature like ZLIB and Lua.

WebUI, since the first day, was designed to only, and only be used with the internal built-in web server. Now, with this commit, and also this one. We can make WebUI use a custom web port, and open a new window with a specific URL. This results in an app that uses NGINX/Apache as a web server for example, while keeping the connection to the back-end using WebUI.

Example:

  1. Run your preferred web server at any port... 8080 for example
  2. Make WebUI use a specific port webui_set_port(win, 9090)
  3. Add webui.js link to your HTML files http://localhost:9090/webui.js
  4. Show a window at the custom web server address webui_show(win, "http://localhost:8080/");

Full example.