Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http.createServer(function (r) {
- if (r.method == 'GET') {
- r.writeResponse(200, {'Content-type': 'text/plain'});
- r.write('hello world\n');
- r.close();
- } else if if (r.method == 'POST') {
- r.writeResponse(200, {'Content-type': 'text/plain'});
- r.close();
- } else {
- r.startResponse(500, {'Content-type': 'text/plain'});
- r.write('error\n');
- r.close();
- }
- });
- // upload
- //
- http.createServer(function (r) {
- var bytes = 0;
- r.addListener('data', function (d) {
- bytes += d.length;
- });
- r.addListener('end', function () {
- r.writeResponse(200, {'Content-type': 'text/plain'});
- r.write('you uploaded ' + bytes + ' bytes\n');
- r.close();
- });
- });
Add Comment
Please, Sign In to add comment