I'm working on a Node.js HTTP server on my iPhone:
var fs = require("fs");
var http = require('http');
const port = 8080;
var readFile = function(name, response) {
var read = function(err, dat) {
var rv = null;
var nope = "./redirect.html";
if (err) {
if (name == nope)
rv = "INTERNET!";
else {
rv = readFile(nope, response);
return;
}
}
else rv = dat;
response.end(rv);
}
fs.readFile(name, "utf-8", read);
}
var client = function(request, response) {
path = "." + request.url;
file = readFile(path, response);
}
var server = http.createServer(client);
server.listen(port);
redirect.html:
<script language = "javascript">
window.location = "/index.html";
</script>
Bad request.