A modern, blazing-fast, and extensible C++ framework for building web servers, static sites, REST/RPC APIs, and even desktop/mobile-like runtimes. Inspired by Express, designed for high performance, POSIX compliance, and hackability.
- Static file serving (HTML, CSS, JS, assets)
- Dynamic routing (REST & RPC-style endpoints)
- Thread pool-based concurrency for high throughput
- CLI-configurable: port, threads, static directory
- Extensible: Compose apps, add middleware, or build full runtimes
- Cross-platform ambitions: Web, desktop, iOS, and more
- Ready for HTTPS (OpenSSL support coming soon)
- POSIX standard: Clean, portable, and robust
docs/
include/
public/
src/
tests/
CMakeLists.txt
README.md
LICENSE
.gitignore
CONTRIBUTING.md
CODE_OF_CONDUCT.md
If you prefer building it directly:
git clone https://github.com/rprakashdass/nanohost.git
cd nanohost
mkdir build && cd build
cmake ..
makeYou’ll get a sample server binary (NanoHostApp) and the NanoHost static library.
If you want to embed NanoHost in your own project manually:
-
Copy the
include/NanoHost/andsrc/folders into your project. -
Add NanoHost source files to your
CMakeLists.txt:add_subdirectory(nanohost) target_link_libraries(your_project PRIVATE NanoHost)
While NanoHost uses .cpp files and is not strictly header-only, you can include only specific headers if you’re building small modules or custom builds:
#include <NanoHost/Router.h>
#include <NanoHost/HTTPResponse.h>Just make sure to link the implementation files or library.
docs/ # Documentation and guides
include/ # Public headers (NanoHost/)
public/ # Static assets directory
src/ # Source files
tests/ # Unit and integration tests
CMakeLists.txt # Build system
README.md # Project overview#include <NanoHost/AppDispatcher.h>
#include <NanoHost/Router.h>
int main() {
Router router;
AppDispatcher app(router);
router.registerRoute("/hello", [](const std::string&) {
return "Hello from NanoHost!";
});
// app.listen(11111);
}- Run the
NanoHostAppexecutable (or your own linked app) from the root folder. - Make sure the
public/folder exists for static file hosting. - Use CLI flags like
--port,--threads, and--staticfor customization.
#include <NanoHost/AppDispatcher.h>
#include <NanoHost/Router.h>
int main() {
Router router;
AppDispatcher app(router);
router.registerRoute("/hello", [](const std::string&) {
return "Hello, world!";
});
// ... add more routes or actions
// app.listen(8080); // (see main.cpp for entrypoint)
}Router::registerRoute(path, handler)— Register REST endpointsRouter::registerAction(action, handler)— Register RPC-style actionsAppDispatcher::HandleRequest(request)— Unified request handlingStaticServer::setStaticDir(path)— Set static file directory- CLI:
--port,--threads,--static
- Add custom middleware, handlers, or integrations
- Compose with other C++ libraries
- See
docs/for extension and architecture guides
- Unit and integration tests in
tests/for routing, HTTP parsing, static serving, and thread pool
See CONTRIBUTING.md and CODE_OF_CONDUCT.md
MIT
- Headers in
include/NanoHost/for easy import - No hardcoded paths; all entrypoints are flexible
- Designed for use as a package in larger C++ projects
- CMake-based build for easy integration