Demo entry 3495780

web

   

Submitted by klauberg on Jan 04, 2016 at 17:24
Language: JavaScript. Code size: 732 Bytes.

(function () {
    'use strict';

    var express = require('express');
    var app = express();

    var fileSystem = require('fs');
    var path = 'caminho/para/produtos.json';

    app.get('/', function (request, response) {
       response.send('Server sendo executado'); 
    });
    
    app.get('/produtos', function (request, response) {
        fileSystem.readFile(path, function (error, data) {
            if (error) throw new Error(error);

            response.setHeader('Content-Type', 'application/json');
            response.send(data);
        });
    });

    app.listen(3124, function () {
        console.log('Server sendo executado em: http://locahost:3124');
    });

}());

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).