Skip to content

Instantly share code, notes, and snippets.

@vickonrails
Last active February 4, 2018 18:14
Show Gist options
  • Save vickonrails/e44169867397c729a3faf418a3127dc6 to your computer and use it in GitHub Desktop.
Save vickonrails/e44169867397c729a3faf418a3127dc6 to your computer and use it in GitHub Desktop.
//server.js file
const express = require('express'),
app = express();
//setting the port
app.set('port', process.env.PORT || 3000);
//
app.get('/',(request,response)=>{
response.sendFile(__dirname +'/form.html');
});
app.get('/process',(request,response)=>{
console.log(request.query);
response.send(`${request.query.name} said ${request.query.message}`);
});
app.listen(3000,()=>{
console.log('Express server started at port 3000');
});
//form.html
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Form page</title>
<style>
*{
margin:0;
padding:0;
box-sizing: border-box;
font-size: 20px;
}
input{
margin:20px;
padding:10px;
}
input[type=”text”],
textarea {
width:200px;
margin:20px;
padding:5px;
height:30px;
display: block;
}
textarea{
resize:none;
height:60px;
}
</style>
</head>
<body>
<form action='/process' method='GET'>
<input type='text' name='name' placeholder='name'/>
<textarea name='message' placeholder='message'></textarea>
<input type='submit'/>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment