Commit fdd0f477 authored by Tung Vu's avatar Tung Vu

jaja

parent be17b1f3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/loesung.iml" filepath="$PROJECT_DIR$/.idea/loesung.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/vorlage.iml" filepath="$PROJECT_DIR$/.idea/vorlage.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
This diff is collapsed.
<h1>Quang Tung Vu</h1>
<p>SMS WS 17 18</p>
\ No newline at end of file
<h1>Dein Name</h1>
<p>SMS WS 17 18</p>
\ No newline at end of file
...@@ -112,7 +112,7 @@ app.defaultConfiguration = function defaultConfiguration() { ...@@ -112,7 +112,7 @@ app.defaultConfiguration = function defaultConfiguration() {
// default configuration // default configuration
this.set('view', View); this.set('view', View);
this.set('files', resolve('files')); this.set('views', resolve('views'));
this.set('jsonp callback name', 'callback'); this.set('jsonp callback name', 'callback');
if (env === 'production') { if (env === 'production') {
...@@ -569,7 +569,7 @@ app.render = function render(name, options, callback) { ...@@ -569,7 +569,7 @@ app.render = function render(name, options, callback) {
view = new View(name, { view = new View(name, {
defaultEngine: this.get('view engine'), defaultEngine: this.get('view engine'),
root: this.get('files'), root: this.get('views'),
engines: engines engines: engines
}); });
...@@ -577,7 +577,7 @@ app.render = function render(name, options, callback) { ...@@ -577,7 +577,7 @@ app.render = function render(name, options, callback) {
var dirs = Array.isArray(view.root) && view.root.length > 1 var dirs = Array.isArray(view.root) && view.root.length > 1
? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"' ? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"'
: 'directory "' + view.root + '"' : 'directory "' + view.root + '"'
var err = new Error('Failed to lookup view "' + name + '" in files ' + dirs); var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs);
err.view = view; err.view = view;
return done(err); return done(err);
} }
......
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); exports.__esModule = true;
var express = require("express"); var express = require("express");
var bodyParser = require("body-parser"); var bodyParser = require("body-parser");
var router = express(); var router = express();
router.use(bodyParser.json()); router.use(bodyParser.json());
router.listen(8080, function () { router.listen(8080, function () {
console.log("Gestartet!");
console.log("Aufrufbar sollten sein: ");
console.log(" http://localhost:8080/name"); console.log(" http://localhost:8080/name");
console.log(" http://localhost:8080/htmlfile"); console.log(" http://localhost:8080/htmlfile");
console.log(" http://localhost:8080/gauss"); console.log(" http://localhost:8080/gauss");
console.log(" http://localhost:8080/liste"); console.log(" http://localhost:8080/liste");
console.log(" http://localhost:8080/object"); console.log(" http://localhost:8080/object");
}); });
router.get("/name", function (req, res) {
res.json({ name: "Peter", nachname: "Kneisel" });
});
router.use("/htmlfile", express.static(__dirname + "/names.html"));
router.get("/gauss", function (req, res) {
var buffer = 0;
for (var i = 1; i <= 100; i++) {
buffer += i;
}
res.json({ ergebnis: buffer });
});
router.get("/liste", function (req, res) {
var buffer = [];
for (var i = 1; i <= 100; i++) {
buffer.push(i);
}
res.json({ ergebnis: buffer });
});
var Person = (function () { var Person = (function () {
function Person(_vorname, _nachname) { function Person(_vorname, _nachname) {
this.vorname = _vorname; this.vorname = _vorname;
...@@ -36,7 +20,8 @@ var Person = (function () { ...@@ -36,7 +20,8 @@ var Person = (function () {
} }
return Person; return Person;
}()); }());
router.get("/object", function (req, res) { router.get("/object", function (req,res) {
var myObject = new Person("Peter", "Kneisel"); let mobject = new Person("Dieter", "Hammer");
res.json(myObject); res.json(mobject);
}); });
//# sourceMappingURL=server.js.map
\ No newline at end of file
{"version":3,"file":"server.js","sourceRoot":"","sources":["server.ts"],"names":[],"mappings":";;AACA,iCAAoC;AACpC,wCAA2C;AAC3C,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;AACvB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH;IAIE,gBAAY,QAAe,EAAE,SAAiB;QAC5C,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IACH,aAAC;AAAD,CAAC,AARD,IAQC"}
\ No newline at end of file
import {Request, Response} from "express"; import {Request, Response} from "express";
import express = require("express"); import express = require("express");
import bodyParser = require("body-parser"); import bodyParser = require("body-parser");
let router = express(); let router = express();
router.use(bodyParser.json()); router.use(bodyParser.json());
router.listen(8080, () => { router.listen(8080, () => {
console.log("Gestartet!");
console.log("Aufrufbar sollten sein: ");
console.log(" http://localhost:8080/name"); console.log(" http://localhost:8080/name");
console.log(" http://localhost:8080/htmlfile"); console.log(" http://localhost:8080/htmlfile");
console.log(" http://localhost:8080/gauss"); console.log(" http://localhost:8080/gauss");
...@@ -12,42 +13,12 @@ router.listen(8080, () => { ...@@ -12,42 +13,12 @@ router.listen(8080, () => {
console.log(" http://localhost:8080/object"); console.log(" http://localhost:8080/object");
}); });
router.get("/name", function (req: Request, res: Response) { class Person{
res.json({name: "Peter", nachname: "Kneisel"}); public vorname: string;
});
router.use("/htmlfile", express.static(`${__dirname}/names.html`));
router.get("/gauss", function (req: Request, res: Response) {
let buffer: number = 0;
for (let i = 1; i <= 100; i++) {
buffer += i
}
res.json({ergebnis: buffer});
});
router.get("/liste", function (req: Request, res: Response) {
let buffer: number[] = [];
for (let i = 1; i <= 100; i++) {
buffer.push(i)
}
res.json({ergebnis: buffer});
});
class Person {
public vorname: string;
public nachname: string; public nachname: string;
constructor(_vorname: string, _nachname: string) { constructor(_vorname:string, _nachname: string) {
this.vorname = _vorname; this.vorname = _vorname;
this.nachname = _nachname; this.nachname = _nachname;
} }
} }
\ No newline at end of file
router.get("/object", function (req: Request, res: Response) {
let myObject = new Person("Peter", "Kneisel");
res.json(myObject);
});
\ No newline at end of file
{
"compilerOptions": {
"sourceMap": true
},
"compileOnSave": true
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="TypeScriptCompiler"> <component name="TypeScriptCompiler">
<option name="isCompilerEnabled" value="true" /> <option name="enableServiceForProjectsWithoutConfig" value="true" />
<option name="useConfig" value="true" /> <option name="recompileOnChanges" value="true" />
</component> </component>
</project> </project>
\ No newline at end of file
This diff is collapsed.
...@@ -5,7 +5,56 @@ var bodyParser = require("body-parser"); ...@@ -5,7 +5,56 @@ var bodyParser = require("body-parser");
var router = express(); var router = express();
router.use(bodyParser.json()); router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: true })); router.use(bodyParser.urlencoded({ extended: true }));
router.listen(8080, function () { router.listen(8080);
console.log("Gestartet: http://localhost:8080/raten/5"); console.log("Gestartet: http://localhost:8080/raten/1");
console.log("Gestartet: http://localhost:8080/cheat/1");
console.log("Gestartet: http://localhost:8080/reset");
function random() {
var min = 1;
var max = 10;
return Math.floor(Math.random() * (max - min)) + min;
}
var ziel = random();
var password = "123123";
router.get("/raten/:zahl", function (req, res) {
var geraten = req.params["zahl"];
if (isNaN(geraten)) {
res.json({ antwort: "Fehler!" });
}
else if (geraten > ziel) {
res.json({ antwort: "Kleiner..." });
}
else if (geraten < ziel) {
res.json({ antwort: "Größer..." });
}
else {
res.json({ antwort: "Richtig!" });
}
});
router.get("/cheat/:password", function (req, res) {
if (req.params["password"] == password) {
res.json({ antwort: ziel });
}
else {
res.json({ antwort: "Passwort abgelehnt!" });
}
});
router.get("/reset", function (req, res) {
ziel = random();
res.json({ antwort: "Neue Zahl." });
});
router.post("/set", function (req, res) {
var newNumber = req.body["new"];
var enteredPassword = req.body["password"];
if (enteredPassword != password) {
res.json({ antwort: "Passwort abgelehnt!" });
return;
}
if (isNaN(newNumber) || newNumber == "") {
res.json({ antwort: "Das ist keine Zahl!" });
return;
}
ziel = newNumber;
res.json({ antwort: "okay" });
}); });
//# sourceMappingURL=express.js.map //# sourceMappingURL=express.js.map
\ No newline at end of file
{"version":3,"file":"express.js","sourceRoot":"","sources":["express.ts"],"names":[],"mappings":";;AACA,iCAAoC;AACpC,wCAA2C;AAE3C,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;AACvB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC"} {"version":3,"file":"express.js","sourceRoot":"","sources":["express.ts"],"names":[],"mappings":";;AACA,iCAAoC;AACpC,wCAA2C;AAE3C,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;AACvB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEpB,OAAO,CAAC,GAA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odyParser = require("body-parser"); ...@@ -5,8 +5,68 @@ import bodyParser = require("body-parser");
let router = express(); let router = express();
router.use(bodyParser.json()); router.use(bodyParser.json());
router.use(bodyParser.urlencoded({extended: true})); router.use(bodyParser.urlencoded({extended: true}));
router.listen(8080, () => { router.listen(8080);
console.log("Gestartet: http://localhost:8080/raten/5");
console.log("Gestartet: http://localhost:8080/raten/1");
console.log("Gestartet: http://localhost:8080/cheat/1");
console.log("Gestartet: http://localhost:8080/reset");
function random(): Number {
let min = 1;
let max = 10;
return Math.floor(Math.random() * (max - min)) + min;
}
let ziel: Number = random();
let password: String = "123123";
router.get("/raten/:zahl", function (req: Request, res: Response) {
let geraten = req.params["zahl"];
if (isNaN(geraten)) {
res.json({antwort: "Fehler!"});
}
else if (geraten > ziel) {
res.json({antwort: "Kleiner..."});
}
else if (geraten < ziel) {
res.json({antwort: "Größer..."});
}
else {
res.json({antwort: "Richtig!"});
}
});
router.get("/cheat/:password", function (req: Request, res: Response) {
if(req.params["password"] == password) {
res.json({antwort: ziel});
}
else {
res.json({antwort: "Passwort abgelehnt!"});
}
}); });
router.get("/reset", function (req: Request, res: Response) {
ziel = random();
res.json({antwort: "Neue Zahl."});
});
router.post("/set", function (req: Request, res: Response) {
let newNumber = req.body["new"];
let enteredPassword = req.body["password"];
if(enteredPassword != password) {
res.json({antwort: "Passwort abgelehnt!"});
return;
}
if(isNaN(newNumber) || newNumber == "") {
res.json({antwort: "Das ist keine Zahl!"});
return;
}
ziel = newNumber;
res.json({antwort: "okay"});
});
{
"message": "Kevin erfolgreich angelegt"
}
\ No newline at end of file
{
"title": "Fidget Spinner"
}
\ No newline at end of file
{
"zahl": "3"
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /raten/5</pre>
</body>
</html>
{
"title2": "Fidget Spinner"
}
\ No newline at end of file
POST http://localhost:8080/user
Content-Type: application/json
{
"name": "Kevin"
}
<> 2018-04-18T021423.200.json
###
POST http://localhost:8080/article
Content-Type: application/json
{
"title": "Fidget Spinner"
}
<> 2018-04-18T114706.200.json
###
GET http://localhost:8080/raten/5
<> 2018-04-18T114554.404.html
###
GET http://localhost:8080/user/3
<> 2018-04-18T114532.200.json
###
POST http://localhost:8080/article
Content-Type: application/json
{
"title": "Fidget Spinner"
}
<> 2018-04-18T114435.200.json
###
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="JavaScriptSettings">
<mapping directory="E:/Studium/Social Media Systems/WEBP2/webP2-SS18-Mahr-Max-Vu" vcs="Git" /> <option name="languageLevel" value="ES6" />
</component> </component>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>