I am new at nodejs so i dont really know how to make this work.
I have code which creates json output when i run node app.js
from my console.
now i want to have the same json output in my website
so if someone enter example.com:8000
it will run the node app.js
My code is:
'use strict';
var pa11y = require();
// Create a test instance with some default options
var test = pa11y({
// Log what's happening to the console
log: {
debug: console.log.bind(console),
error: console.error.bind(console),
info: console.log.bind(console)
}
});
test.run('example.com', function(error, result) {
if (error) {
return console.error(error.message);
}
console.log(JSON.stringify(result));
});
UPDATE:
i have tried to use expressjs
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send("Hello world!");
test.run('example.com', function(error, result) {
if (error) {
return console.error(error.message);
}
console.log(JSON.stringify(result));
});
});
"Hello word" is working fine.
and all what i have tried to print the output from the test.run('example.com', function(error, result) {
without any success.
what i need to do to make this work with expressjs