You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. var express = require('express');
  2. let res = require('express/lib/response');
  3. var router = express.Router();
  4. /* GET home page. */
  5. router.get('/', function (req, res, next) {
  6. res.render('index', { title: 'Startseite' });
  7. });
  8. router.get('/contact', function (req, res, next) {
  9. res.render('contact', { title: 'Kontakt', alter: '' });
  10. });
  11. router.get('/portfolio', function (req, res, next) {
  12. res.render('portfolio', { title: 'Portfolio' });
  13. });
  14. router.get('/neuePerson', function (req, res, next) {
  15. console.log(req.query); //zeigt alles an, was an Route gesendet wurde
  16. let lname = req.query.nachname;
  17. let fname = req.query.vorname;
  18. let city = req.query.wohnort;
  19. let plz = req.query.postleitzahl;
  20. let street = req.query.strasse;
  21. let number = req.query.hausnummer;
  22. let email = req.query.email;
  23. let bday = req.query.geburtstag;
  24. console.log(fname, lname, street, number, plz, city, bday, email); //console.log als debug-Instrument
  25. console.log(bday);
  26. let date_birth = new Date(bday).getTime();
  27. let date_now = new Date(Date.now()).getTime();
  28. let days = ((((date_now - date_birth) / 1000) / 60) / 60) / 24;
  29. console.log(days);
  30. if (days == 'NAN') {
  31. days = 'ungültig';
  32. }
  33. let meinAlter = 'Ich bin ' + Math.round(days) + 'Tage alt!'
  34. res.render('contact', { title: 'Kontakt', alter: meinAlter });
  35. });
  36. module.exports = router;