Skip to content

Commit

Permalink
(feat): add basic api stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mpabst-udg committed Feb 9, 2024
1 parent 3061c88 commit 0ecc5f0
Show file tree
Hide file tree
Showing 3 changed files with 743 additions and 0 deletions.
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// express und http Module importieren. Sie sind dazu da, die HTML-Dateien
// aus dem Ordner "public" zu veröffentlichen.
var express = require("express");
const cookieParser = require("cookie-parser");

const app = express();
app.use(cookieParser());

var server = require("http").createServer(app);
var port = 3000;

server.listen(port, function () {
console.log("Server listening on port " + port);
});

app.get("/list", (req, res, next) => {
res.json(["Tony", "Lisa", "Michael", "Ginger", "Food"]);
});

app.get("/inc", (req, res, next) => {
var inc = parseInt(req.cookies["inc"]);
if (isNaN(inc)) {
inc = 0;
}
res.cookie("inc", ++inc, { maxAge: 10800 }).send("cookie set to" + inc);
});
Loading

0 comments on commit 0ecc5f0

Please sign in to comment.