diff --git a/include/webui.h b/include/webui.h index 45f3c0d63..2ce517bbc 100644 --- a/include/webui.h +++ b/include/webui.h @@ -595,6 +595,15 @@ WEBUI_EXPORT void webui_set_proxy(size_t window, const char* proxy_server); */ WEBUI_EXPORT const char* webui_get_url(size_t window); +/** + * @brief Open an URL in the native default web browser. + * + * @param url The URL to open + * + * @example webui_open_url("https://webui.me"); + */ +WEBUI_EXPORT void webui_open_url(const char* url); + /** * @brief Allow a specific window address to be accessible from a public network. * diff --git a/src/webui.c b/src/webui.c index 13accc67d..e90afc97c 100644 --- a/src/webui.c +++ b/src/webui.c @@ -2612,6 +2612,18 @@ void webui_set_proxy(size_t window, const char* proxy_server) { win->proxy_set = true; } +void webui_open_url(const char* url) { + + #ifdef WEBUI_LOG + printf("[User] webui_open_url([%s])\n", url); + #endif + + // Initialization + _webui_init(); + + _webui_open_url_native(url); +} + const char* webui_get_url(size_t window) { #ifdef WEBUI_LOG @@ -7495,6 +7507,8 @@ static void _webui_http_send_file( // Send body mg_send_file_body(client, path); + + fclose(file); } static void _webui_http_send(