1.0.7 • Published 7 years ago

piov v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

#PIOV This is lite server for nodejs

###Open Command prompt:

mkdir node-project #Create project folder
cd node-project #CD to your project folder
npm i piov #Install piov
#Or
npm install piov

###Example 1 : Edit server file > node-project/server.js

const piov	= require('piov');
const http	= require('http').Server(piov).listen(4000);

// node-project/index.html
// Open url: http://localhost:4000
const piov	= require('piov').set();
const http	= require('http').Server(piov).listen(4000);

// node-project/index.html
// Open url: http://localhost:4000
const piov	= require('piov').set('public','index.html');
const http	= require('http').Server(piov).listen(4000);

// node-project/public/
// node-project/public/index.html
// Open url: http://localhost:4000

###Example 2 : Edit server file > node-project/server.js

const http	= require('piov').server();

// node-project/index.html
// Open url: http://localhost:8080
const http	= require('piov').server(/*listen PORT*/ 4000);

// node-project/index.html
// Open url: http://localhost:4000
const http	= require('piov').server(/*listen PORT*/ '4000', /*folder public*/ 'public', /*file public/index.html*/ 'index.html');

// node-project/public/
// node-project/public/index.html
// Open url: http://localhost:4000

###Example 3 : Edit server file > node-project/server.js Use socket.io: npm install socket.io

/*const io	= require('piov').socket(); // Open url: http://localhost:8080 */
/*const io	= require('piov').socket(/*listen PORT*/ 4000);*/
// node-project/index.html
const io	= require('piov').socket(/*listen PORT*/ '4000', /*folder public*/ 'public', /*file public/index.html*/ 'index.html');

io.of('/index1.html').on('connection',socket=>{
		console.log('Socket connected '+socket.id);
		socket.on('disconnect',function(){console.log('Socket disconnected '+socket.id);});
	});
io.of('/index2.html').on('connection',socket=>{
		console.log('Socket connected '+socket.id);
		socket.on('disconnect',function(){console.log('Socket disconnected '+socket.id);});
	});

// node-project/public/
// node-project/public/index.html
// node-project/public/index1.html
// node-project/public/index2.html

// Open url: http://localhost:4000/index1.html
// Open url: http://localhost:4000/index2.html

Edit index file > node-project/public/index1.html

<script src="socket.io/socket.io.js"></script>

<script>
	var socket = io('http://localhost:4000/index1.html');
</script>

Edit index file > node-project/public/index2.html

<script src="socket.io/socket.io.js"></script>

<script>
	var socket = io('http://localhost:4000/index2.html');
</script>
1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago