+
Erabiltzailea:
+
+
Oharra: sartzen duzun izena 15 minutuan iraungitzen den cookie batean gordeko da.
+
+
+
+
+
diff --git a/ariketa-02/index.js b/ariketa-02/index.js
new file mode 100644
index 0000000..be87b96
--- /dev/null
+++ b/ariketa-02/index.js
@@ -0,0 +1,39 @@
+const express = require('express');
+const app = express();
+const path = require('path');
+const bodyParser= require('body-parser');
+
+app.set('port', 8080);
+app.use(express.static(path.join(__dirname, 'public')));
+app.use(bodyParser.urlencoded({extended: true}));
+app.use(bodyParser.json());
+
+app.get('/', (req, res) => {
+ res.status(200).sendFile(__dirname + '/index.html');
+});
+
+app.get('/irudiak', (req, res) => {
+ res.status(200).sendFile(__dirname + '/irudiak.html');
+});
+
+app.get('/irudi_:num', (req, res) =>{
+ var num = req.params.num;
+ res.status(200).sendFile(__dirname + '/irudi_'+num+'.html');
+});
+
+app.get('*', (req, res, next) => {
+ res.status(200).send('Eskatu duzun orrialdea ez da aurkitu!');
+ next();
+});
+
+app.post('/',(req, res) => {
+ console.log(req.body);
+ if(req.body.username != ''){
+ res.cookie('username', req.body.username, { expires: new Date(Date.now() + 900000), 'sameSite':'lax'})
+ }
+ res.status(200).sendFile(__dirname + '/index.html');
+});
+
+app.listen(app.get('port'), () => {
+ console.log('Zerbitzaria martxan ' + app.get('port') + ' atakan');
+});
diff --git a/ariketa-02/irudi_1.html b/ariketa-02/irudi_1.html
new file mode 100644
index 0000000..2984ff0
--- /dev/null
+++ b/ariketa-02/irudi_1.html
@@ -0,0 +1,17 @@
+
+
+
+