"use strict";

/* Express web server instellen */
const express = require('express');
const server = express();

const cors = require('cors');
server.use(cors());
server.options('*', cors());	// voor nu even helemaal open zetten

const querystring = require('querystring');

const LOCAL_PORT = "1234";

let dataSet =
		{
			"merk": "BMW",
			"type": "2002 Turbo"
		};

// STATIC FILES HOSTEN:
server.get(['/','/testpagina.html'], function(request, response) {
    console.log('Get of /');
	
	response.sendFile(__dirname + '/testpagina.html');
});



/* GET bericht (random) */
server.get('/jsonp', function (request, response) {

        console.log("We zijn hier in jsonp functie");
		console.log(request.query.functie);
		response.send(request.query.functie +'(' + JSON.stringify(dataSet) + ')');
});


/* Webserver starten */
server.listen(LOCAL_PORT, function() {
    console.log('Server started!');	
});
