WebFund 2016W Lecture 7: Difference between revisions

From Soma-notes
LeeCroft (talk | contribs)
No edit summary
No edit summary
Line 8: Line 8:


https://pollev.com/anilsomayaji565
https://pollev.com/anilsomayaji565
==Code==
<source lang="javascript" line>
var http = require('http');
var request_handler = function(request, response) {
    var body_content;
    console.log("I got a request for: " + request.url);
    response.writeHead(404, {
        "Content-Type": "text/html"
    });
    body_content = "You requested: " + request.url;
   
    response.write("<html>\n<head>\n<title>Hello!</title>\n</head>" +
  "<body><h1>Hello world!</h1>" +
  "<p>" + body_content + "</p>" +
  "<script>alert('where does this print');</script> " +
  "\n</body>\n</html>\n");
    return response.end();
}
var server = http.createServer(request_handler);
server.listen(8000, "localhost", function() {
    return console.log("Server listening at http://localhost:8000/");
});
console.log("Finished!");
</source>

Revision as of 15:53, 30 January 2016

Video

The video for the lecture given on January 28, 2016 is now available.

Notes

In-class Poll

https://pollev.com/anilsomayaji565

Code

var http = require('http');

var request_handler = function(request, response) {

    var body_content;

    console.log("I got a request for: " + request.url);

    response.writeHead(404, {
        "Content-Type": "text/html"
    });

    body_content = "You requested: " + request.url;
    
    response.write("<html>\n<head>\n<title>Hello!</title>\n</head>" +
		   "<body><h1>Hello world!</h1>" +
		   "<p>" + body_content + "</p>" +
		   "<script>alert('where does this print');</script> " +
		   "\n</body>\n</html>\n");

    return response.end();
}

var server = http.createServer(request_handler);

server.listen(8000, "localhost", function() {
    return console.log("Server listening at http://localhost:8000/");
});

console.log("Finished!");