Tuesday, 7 August 2018

I have a big problem but don't know how to solve it

The index file that takes forms from localhost:3000 :var express = require('express')var bodyParser = require('body-parser')var app = express()app.use(bodyParser.text())I want the form code hereapp.listen(3000)the test form code:app.post('/receivesdatafromthisurl', (request, response) => {console.log(response)})Since I'm making multiple forms I want them to exist in different files to stay organized but use the same localhost port, how would I make the app.post function be where I want it to be, while keeping it another file. I tried using module.exports, but the module needs it's own app.listen and variable initializations. Basically what I'm trying to say is have that app.post code be in another file, but pretends it's in that one

Submitted August 08, 2018 at 07:02AM by smiles_low

No comments:

Post a Comment