Skip to content

Instantly share code, notes, and snippets.

@petermikitsh
Created March 7, 2022 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermikitsh/ea709b40655930bbf6520a68e76399ce to your computer and use it in GitHub Desktop.
Save petermikitsh/ea709b40655930bbf6520a68e76399ce to your computer and use it in GitHub Desktop.
Form post demo
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.send(`
<form action="/Form.do" method="POST">
<div>
<button>Submit the form</button>
</div>
</form>
`);
})
app.post('/Form.do', (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.send(`
Form submitted. This is the response.
`);
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment