Skip to content

lordrasmus/libcwebui

Repository files navigation

libcwebui

Build Status Scan Status license language

compact webserver library for WebUIs

##Features:

  • Small ( usable in Embedded Systems )
  • Fast
  • SSL
  • Websocket Support
  • Template Engine
  • Python Plugin Support
  • Portable

Sample

Files

  • main.c
  • plugin.py
  • www/index.html
  • img/img.jpg

main.c

int main(int argc, char **argv) {
	
	   if (0 == WebserverInit()) {

       		WebserverConfigSetInt("port",8080);
    		WebserverAddFileDir("", "www");
    		WebserverAddFileDir("img", "img");

            WebserverInitPython();
            WebserverLoadPyPlugin( "plugin.py" );

    		WebserverStart();
    	}
    	return 0;
}

plugin.py

import libcwebui

def func1(  ):
    libcwebui.send( "  render b : " )
    libcwebui.setRenderVar( "render1" )

libcwebui.set_plugin_name("PyPlugin")
libcwebui.register_function( func1 )

www/index.html

TEMPLATE_V1
Call Function   : {f:func1}
Render Variable : {get:render;"render1"}