GithubHelp home page GithubHelp logo

lib_nodepp's Introduction

A high level library to let me do asynchronous c++ programming like that done in Node.js.

#include <cstdlib>

#include "base_work_queue.h"
#include "lib_http_request.h"
#include "lib_http_site.h"
#include "lib_http_static_service.h"

int main( int argc, char const **argv ) {
	using namespace daw::nodepp;
	using namespace daw::nodepp::lib::net;
	using namespace daw::nodepp::lib::http;

	auto site = create_http_site( );
	site->on_listening( []( EndPoint endpoint ) {
				std::cout << "Node++ Static HTTP Server\n";
				std::cout << "Listening on " << endpoint << '\n';
			} )
			.on_error( []( base::Error error ) {
				std::cerr << "Error: ";
				std::cerr << error << '\n';
			} )
			.listen_on( 8080 );

	auto service = create_static_service( "/", "./web_files" );
	service->connect( site );

	base::start_service( base::StartServiceMode::OnePerCore );
	return EXIT_SUCCESS;
}

As you can see, one can create a static web server quickly and succinctly. Currently, the library focus is on networking and HTTP networking. Other async tasks will be added, such as Sqlite support as I need them. The tests folder contains more examples.

lib_nodepp's People

Contributors

beached avatar

Watchers

James Cloos avatar  avatar skyformat99 avatar  avatar

Forkers

skyformat99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.