Skip to content

technicalrockstars/hx-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hx-node

Extern NodeJs library on Haxe

Installation

Using Haxelib install:

haxelib isntall hx-node

or using local install script

git clone https://github.com/technicalrockstars/hx-node
./loca.sh

Code Examples

package ;

import node.Node;
import node.http.Server;
import node.http.Http;
import node.URL;

using node.http.Server.ServerEvent;
using node.http.ClientRequest.ClientRequestEvent;
using node.http.ServerResponse.ServerResponseEvent;

class NodeServerExample{
	public static function main(){
		var sendText = 'Hello World!\n';

		// creating Server
		var server = Http.createServer();
		server.onRequest(function(req,res){
			res.writeHead(200,{'Content-Type': 'text/plain'});
			res.end(sendText);
		});
		server.listen(3000);

		// access server
		var request = Http.request(URL.parse("http://localhost:3000"));
		request.onResponse(function(res){
			res.onData(function(data){
				trace(Std.string(data));
				// server close
				server.close();
			});
		});
		request.end();
	}
}

About

Extern NodeJs library on Haxe

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published