@@ -17,6 +17,26 @@ app.use(function (req, res, next) {
1717 next ( ) ;
1818} ) ;
1919
20+
21+ const { WatsonMLScoringEndpoint } = require ( "watson-ml-model-utils" ) ;
22+
23+
24+ var features = [ 'LOTAREA' , 'BLDGTYPE' , 'HOUSESTYLE' , 'OVERALLCOND' , 'YEARBUILT' ,
25+ 'ROOFSTYLE' , 'EXTERCOND' , 'FOUNDATION' , 'BSMTCOND' , 'HEATING' ,
26+ 'HEATINGQC' , 'CENTRALAIR' , 'ELECTRICAL' , 'FULLBATH' , 'HALFBATH' ,
27+ 'BEDROOMABVGR' , 'KITCHENABVGR' , 'KITCHENQUAL' , 'TOTRMSABVGRD' ,
28+ 'FIREPLACES' , 'FIREPLACEQU' , 'GARAGETYPE' , 'GARAGEFINISH' , 'GARAGECARS' ,
29+ 'GARAGECOND' , 'POOLAREA' , 'POOLQC' , 'FENCE' , 'MOSOLD' , 'YRSOLD' ] ;
30+
31+ let endpoint = new WatsonMLScoringEndpoint ( features , {
32+ servicePath : 'https://ibm-watson-ml.mybluemix.net' ,
33+ username : '04c75888-357b-4548-9a3d-824b0fdf4355' ,
34+ password : '1626bb66-81f2-4d17-962d-b750eedce230' ,
35+ instanceId : 'ee215244-7c33-4ffb-ae7f-e2aac55d92f4' ,
36+ modelId : 'fbb8ab9f-4600-470b-95f0-55dd30925d6e' ,
37+ deploymentId : 'c3cf73a6-4cbb-493f-879d-e60d30c3f26f'
38+ } ) ;
39+
2040var NodeGeocoder = require ( 'node-geocoder' ) ;
2141
2242var options = {
@@ -34,6 +54,8 @@ var geocoder = NodeGeocoder(options);
3454let connStr = "DATABASE=" + process . env . DB_DATABASE + ";HOSTNAME=" + process . env . DB_HOSTNAME + ";PORT=" + process . env . DB_PORT + ";PROTOCOL=TCPIP;UID=" + process . env . DB_UID + ";PWD=" + process . env . DB_PWD + ";" ;
3555
3656
57+
58+
3759//let connStr = "DATABASE=BLUDB;HOSTNAME=db2whoc-flex-zipnqsp.services.au-syd.bluemix.net;PORT=50000;PROTOCOL=TCPIP;UID=bluadmin;PWD=zWG@U4q1uFpDTi0v8jVBDI7_PtSr0;";
3860
3961 app . post ( '/newDataEntry' , function ( request , response ) {
@@ -77,7 +99,8 @@ let connStr = "DATABASE="+process.env.DB_DATABASE+";HOSTNAME="+process.env.DB_HO
7799
78100} )
79101
80- app . post ( '/getData' , function ( request , response ) {
102+ app . post ( '/getData' , function ( request , response ) {
103+ console . log ( 'hi' )
81104 ibmdb . open ( connStr , function ( err , conn ) {
82105 if ( err ) {
83106 return response . json ( { success :- 1 , message :err } ) ;
@@ -93,7 +116,7 @@ app.post('/getData', function(request, response){
93116 } ) ;
94117} )
95118
96- app . post ( '/getUniqueData' , function ( request , response ) {
119+ app . post ( '/getUniqueData' , function ( request , response ) {
97120 ibmdb . open ( connStr , function ( err , conn ) {
98121 if ( err ) {
99122 return response . json ( { success :- 1 , message :err } ) ;
@@ -123,7 +146,7 @@ app.post('/getUniqueData', function(request, response){
123146 } ) ;
124147} )
125148
126- app . post ( '/updateDataEntry' , function ( request , response ) {
149+ app . post ( '/updateDataEntry' , function ( request , response ) {
127150 ibmdb . open ( connStr , function ( err , conn ) {
128151 if ( err ) {
129152 return response . json ( { success :- 1 , message :err } ) ;
@@ -179,7 +202,7 @@ app.post('/updateDataEntry', function(request, response){
179202} )
180203
181204
182- app . post ( '/deleteData' , function ( request , response ) {
205+ app . post ( '/deleteData' , function ( request , response ) {
183206 ibmdb . open ( connStr , function ( err , conn ) {
184207 if ( err ) {
185208 return response . json ( { success :- 1 , message :err } ) ;
@@ -203,7 +226,16 @@ app.post('/deleteData', function(request, response){
203226 } ) ;
204227} )
205228
206- app . get ( '/predict' , function ( request , response ) {
229+
230+ app . post ( '/WML_Predict' , function ( request , response ) {
231+ endpoint . score ( request . body . values ) . then (
232+ output => {
233+ console . log ( output . prediction ) ;
234+ return response . json ( { success :1 , value :output . prediction } ) ;
235+ } ) . catch ( err => console . log ( err ) ) ;
236+ } )
237+
238+ app . get ( '/predict' , function ( request , response ) {
207239 console . log ( request ) ;
208240 return response . json ( {
209241 "address1" :"10892 Northfield Sq" ,
0 commit comments