Home  /  Documentation  /  Examples  /  REQ demo

REQ demo

This is a simple 2-pages application demonstrating basic REQ and OUT macros usage.

npp_app.cpp

void npp_app_main() { if ( REQ("") ) // landing page { OUT_HTML_HEADER; OUT("<h1>%s</h1>", NPP_APP_NAME); OUT("<h2>Welcome to my web app!</h2>"); OUT("<p><a href=\"/about\">About</a></p>"); OUT_HTML_FOOTER; } else if ( REQ("about") ) { OUT_HTML_HEADER; OUT("<h1>%s</h1>", NPP_APP_NAME); OUT("<h2>About</h2>"); OUT("<p>Hello World Sample Node++ Web Application</p>"); OUT("<p><a href=\"/\">Back to landing page</a></p>"); OUT_HTML_FOOTER; } else // page not found { RES_STATUS(404); } }