res.type('html'); res.write(plugin[util.PLUGIN_MENU_CONFIG]); res.write(MENU_HTML);
app.get('/headers', (req, res) => { res.type('text/plain') var s = '' for (var name in req.headers) s += name + ': ' + req.headers[name] + '\n' res.send(s) })
// Authentication Recording app.post('/authenticate', function(req, res) { var twiml = new VoiceResponse(); utilities.speak(twiml, 'Please say the following phrase to authenticate '); utilities.speak(twiml, config.chosenVoicePrintPhrase, config.contentLanguage); twiml.record({ action: '/process_authentication', maxLength: '5', trim: 'do-not-trim', }); res.type('text/xml'); res.send(twiml.toString()); });
app.get('/rss', async (req, res) => { let [news] = await getLatestNews(); let rss = $h.rss({version: '2.0', 'xmlns:atom': 'http://www.w3.org/2005/Atom'}, $h.channel( $h.title(siteName) + ' ' + `<link>${siteUrl}</link>` + ' ' + $h.description(siteDescription) + ' ' + newsListToRSS(news) ) ); res.type('xml').send(rss); });
@Get('/sitemap.xml') async sitemap(@Res() res: Response) { const body = await this.appService.sitemap(); return res.type('xml').send(body); }
//another middleware : File Not found error app.use(function(req,res){ res.type('text/html'); res.status(404); res.render('404'); });
app.get('/qrcode', (req, res) => { const url = 'https://www.diogocezar.com'; const code = qr.image(url, {type : 'svg'}); res.type('svg'); code.pipe(res); });
app.get('/api',function(req,res){ res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Headers", "Content-Type,X-Requested-With"); res.setHeader("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS"); res.setHeader("X-Powered-By",' 3.2.1'); res.type("application/json"); res.type("jpg"); res.sendFile(path.join(__dirname,'admin','admin.html')); });
app.get('/', function (req, res) { var store = { list: ['foo', 'bar'] }; var app = React.renderToString(AppWrapper({store: store})); var html = index.replace('{{APP}}', app).replace('{{STORE}}', JSON.stringify(store)); res.type('html'); res.send(html); });
// start() is the starting point of the web server start() { app.get('/', (req, res) => { res.type('application/json'); // We are getting the current API number via the interface we injected // from the constructor res.status(200).send(this.webserverInterface.displayApiVersion()); }); app.listen(3000, () => { console.log('Example app listening on port 3000!'); }); }
app.get('/shibboleth/metadata', function(req, res) { res.type('application/xml'); res.status(200).send(samlStrategy.generateServiceProviderMetadata( fs.readFileSync(__dirname + '/cert/decryption_cert.pem', 'utf8'), fs.readFileSync(__dirname + '/cert/signing_cert.pem', 'utf8') )); } );
app.get('/api/users', (req, res) => { res.type('application/json'); try { User.findAll().then(function (results) { res.send(results); }); } catch (error) { res.send({ 'error': error }); } });
@Get('/rss') async rss(@Res() res: Response) { const body = await this.appService.rss(); return res.type('xml').send(body); }
// ------ Define express endpoints ------ // Endpoint to retrieve metadata app.get("/metadata.xml", function(req, res) { res.type('application/xml'); res.send(sp.create_metadata()); });
//Render a plain text for test page app.get('/test', function(req, res){ res.type('text/plain'); res.send('this is a test'); });