Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
¿Cómo puedo crear con éxito un formulario simple usando nodejs sin módulos externos?

Así que he estado trabajando en esto por un tiempo:

 /* API 1 Docs: https://docs.genius.com/#/getting-started-h1 API 2 Docs: https://pastebin.com/doc_api */ let https = require('https') //const qs = require('querystring'); function handler(req, res){ if(req.method == "GET"){ res.setHeader('Content-Type', 'text/html'); res.writeHead(200); res.end("<html><body><form action='/' method='post'><input type='text' name='hello'><input type='submit'></form></body></html>"); } else if(req.method == 'POST'){ res.setHeader('Content-Type', 'text/html'); res.writeHead(200); res.end(`<html>Success Posting!</html>`) /* var body; req.on('data', function(data) { body += data; if (body.length > 1e6) { // FLOOD ATTACK OR FAULTY CLIENT, NUKE REQUEST req.connection.destroy(); } }); req.on('end', function() { var POST = qs.parse(body); let data = POST.submit res.end(`<html>${data}</html>`) }); */ } else { res.writeHead(200); res.end(); }; }; https.createServer(handler).listen(3000, function(err) { if (err) { console.log('Error starting https server'); } else { console.log('Server listening on port 3000'); }; });

(Ignore el código comentado) Lo tenía funcionando antes y, de repente, dejó de funcionar, creó un formulario y, al enviarlo, cambiaría la página a "Publicación exitosa", pero ahora, de repente, no es así y he sido haciendo pequeños cambios sin saber mi problema

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que necesito crear un servidor http usando el módulo http en lugar de hacer un servidor https con el módulo https

Antes:

 const https = require('https') https.createServer(handler).listen(3000, function(err) { if (err) { console.log('Error starting https server'); } else { console.log('Server listening on port 3000'); }; });

Después:

 const http = require('http') http.createServer(handler).listen(3000, function(err) { if (err) { console.log('Error starting http server'); } else { console.log('Server listening on port 3000'); }; });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!