Created
June 30, 2011 02:35
-
-
Save karschsp/1055507 to your computer and use it in GitHub Desktop.
Trying to read post in node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = express.createServer(express.logger(), express.bodyParser(), function(req, res){ | |
switch (req.url) { | |
case '/': | |
res.write( | |
'<h1>ZIP Lookup</h1>'+ | |
'<form method="post" action="/lookup" enctype="multipart/form-data">'+ | |
'<fieldset>'+ | |
'<label for="zip">Zip: </label>'+ | |
'<input type="text" name="zip" id="zip"></input>'+ | |
'<input type="submit" value="Submit" />'+ | |
'</fieldset>'+ | |
'</form>' | |
); | |
res.end(); | |
break; | |
case '/lookup': | |
if (req.method == 'POST') { | |
res.write('Zip: ' + req.body.zip); | |
} | |
res.end(); | |
break; | |
} | |
}).listen(3000,"127.0.0.1"); | |
sys.puts("Server running on port 3000"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment