@@ -17,6 +17,27 @@ 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+
32+ let endpoint = new WatsonMLScoringEndpoint ( features , {
33+ servicePath : process . env . WML_SERVICEPATH ,
34+ username : process . env . WML_UID ,
35+ password : process . env . WML_PWD ,
36+ instanceId : process . env . WML_INSTANCEID ,
37+ modelId : process . env . WML_MODELID ,
38+ deploymentId : process . env . WML_DEPLOYMENTID
39+ } ) ;
40+
2041var NodeGeocoder = require ( 'node-geocoder' ) ;
2142
2243var options = {
@@ -34,6 +55,8 @@ var geocoder = NodeGeocoder(options);
3455let 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 + ";" ;
3556
3657
58+
59+
3760//let connStr = "DATABASE=BLUDB;HOSTNAME=db2whoc-flex-zipnqsp.services.au-syd.bluemix.net;PORT=50000;PROTOCOL=TCPIP;UID=bluadmin;PWD=zWG@U4q1uFpDTi0v8jVBDI7_PtSr0;";
3861
3962 app . post ( '/newDataEntry' , function ( request , response ) {
@@ -77,7 +100,8 @@ let connStr = "DATABASE="+process.env.DB_DATABASE+";HOSTNAME="+process.env.DB_HO
77100
78101} )
79102
80- app . post ( '/getData' , function ( request , response ) {
103+ app . post ( '/getData' , function ( request , response ) {
104+ console . log ( 'hi' )
81105 ibmdb . open ( connStr , function ( err , conn ) {
82106 if ( err ) {
83107 return response . json ( { success :- 1 , message :err } ) ;
@@ -93,7 +117,7 @@ app.post('/getData', function(request, response){
93117 } ) ;
94118} )
95119
96- app . post ( '/getUniqueData' , function ( request , response ) {
120+ app . post ( '/getUniqueData' , function ( request , response ) {
97121 ibmdb . open ( connStr , function ( err , conn ) {
98122 if ( err ) {
99123 return response . json ( { success :- 1 , message :err } ) ;
@@ -123,7 +147,7 @@ app.post('/getUniqueData', function(request, response){
123147 } ) ;
124148} )
125149
126- app . post ( '/updateDataEntry' , function ( request , response ) {
150+ app . post ( '/updateDataEntry' , function ( request , response ) {
127151 ibmdb . open ( connStr , function ( err , conn ) {
128152 if ( err ) {
129153 return response . json ( { success :- 1 , message :err } ) ;
@@ -179,7 +203,7 @@ app.post('/updateDataEntry', function(request, response){
179203} )
180204
181205
182- app . post ( '/deleteData' , function ( request , response ) {
206+ app . post ( '/deleteData' , function ( request , response ) {
183207 ibmdb . open ( connStr , function ( err , conn ) {
184208 if ( err ) {
185209 return response . json ( { success :- 1 , message :err } ) ;
@@ -203,7 +227,16 @@ app.post('/deleteData', function(request, response){
203227 } ) ;
204228} )
205229
206- app . get ( '/predict' , function ( request , response ) {
230+
231+ app . post ( '/WML_Predict' , function ( request , response ) {
232+ endpoint . score ( request . body . values ) . then (
233+ output => {
234+ console . log ( output . prediction ) ;
235+ return response . json ( { success :1 , value :output . prediction } ) ;
236+ } ) . catch ( err => console . log ( err ) ) ;
237+ } )
238+
239+ app . get ( '/predict' , function ( request , response ) {
207240 console . log ( request ) ;
208241 return response . json ( {
209242 "address1" :"10892 Northfield Sq" ,
0 commit comments