Created
March 7, 2022 07:41
-
-
Save petermikitsh/ea709b40655930bbf6520a68e76399ce to your computer and use it in GitHub Desktop.
Form post demo
This file contains 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
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