GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — alchemyapi_node/app.js at master · AlchemyAPI/alchemyapi_node
This repository was archived by the owner on Oct 30, 2018. It is now read-only.
Expand file tree/ Copy pathapp.jsMore file actions 191 lines (142 loc) · 5.93 KB / Copy pathapp.jsFile metadata and controls191 lines (142 loc) · 5.93 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 /** Copyright 2014 AlchemyAPI Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ var express = require('express'); var consolidate = require('consolidate'); var app = express(); var server = require('http').createServer(app); //Create the AlchemyAPI object var AlchemyAPI = require('./alchemyapi'); var alchemyapi = new AlchemyAPI(); // all environments app.engine('dust',consolidate.dust); app.set('views',__dirname + '/views'); app.set('view engine', 'dust'); app.set('port', process.env.PORT || 3000); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } app.get('/', example); var port = process.env.PORT || 3000; server.listen(port, function(){ console.log('Express server listening on port ' + port); console.log('To view the example, point your favorite browser to: localhost:3000'); }); var demo_text = 'Yesterday dumb Bob destroyed my fancy iPhone in beautiful Denver, Colorado. I guess I will have to head over to the Apple Store and buy a new one.'; var demo_url = 'http://www.npr.org/2013/11/26/247336038/dont-stuff-the-turkey-and-other-tips-from-americas-test-kitchen'; var demo_html = '<html><head><title>Node.js Demo | AlchemyAPI</title></head><body><h1>Did you know that AlchemyAPI works on HTML?</h1><p>Well, you do now.</p></body></html>'; function example(req, res) { var output = {}; //Start the analysis chain entities(req, res, output); } function entities(req, res, output) { alchemyapi.entities('text', demo_text,{ 'sentiment':1 }, function(response) { output['entities'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response['entities'] }; keywords(req, res, output); }); } function keywords(req, res, output) { alchemyapi.keywords('text', demo_text, { 'sentiment':1 }, function(response) { output['keywords'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response['keywords'] }; concepts(req, res, output); }); } function concepts(req, res, output) { alchemyapi.concepts('text', demo_text, { 'showSourceText':1 }, function(response) { output['concepts'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response['concepts'] }; sentiment(req, res, output); }); } function sentiment(req, res, output) { alchemyapi.sentiment('html', demo_html, {}, function(response) { output['sentiment'] = { html:demo_html, response:JSON.stringify(response,null,4), results:response['docSentiment'] }; text(req, res, output); }); } function text(req, res, output) { alchemyapi.text('url', demo_url, {}, function(response) { output['text'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; author(req, res, output); }); } function author(req, res, output) { alchemyapi.author('url', demo_url, {}, function(response) { output['author'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; language(req, res, output); }); } function language(req, res, output) { alchemyapi.language('text', demo_text, {}, function(response) { output['language'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response }; title(req, res, output); }); } function title(req, res, output) { alchemyapi.title('url', demo_url, {}, function(response) { output['title'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; relations(req, res, output); }); } function relations(req, res, output) { alchemyapi.relations('text', demo_text, {}, function(response) { output['relations'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response['relations'] }; category(req, res, output); }); } function category(req, res, output) { alchemyapi.category('text', demo_text, {}, function(response) { output['category'] = { text:demo_text, response:JSON.stringify(response,null,4), results:response }; feeds(req, res, output); }); } function feeds(req, res, output) { alchemyapi.feeds('url', demo_url, {}, function(response) { output['feeds'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response['feeds'] }; microformats(req, res, output); }); } function microformats(req, res, output) { alchemyapi.microformats('url', demo_url, {}, function(response) { output['microformats'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response['microformats'] }; taxonomy(req, res, output); }); } function taxonomy(req, res, output) { alchemyapi.taxonomy('url', demo_url, {}, function(response) { output['taxonomy'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; combined(req, res, output); }); } function combined(req, res, output) { alchemyapi.combined('url', demo_url, {}, function(response) { output['combined'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; image(req, res, output); }); } function image(req, res, output) { alchemyapi.image('url', demo_url, {}, function(response) { output['image'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; image_keywords(req, res, output); }); } function image_keywords(req, res, output) { alchemyapi.image_keywords('url', demo_url, {}, function(response) { output['image_keywords'] = { url:demo_url, response:JSON.stringify(response,null,4), results:response }; res.render('example',output); }); } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |