How to make API by using Flask Python












-2















I am trying to make a API for my SVM model to predict the data through API.



I have tried below code but getting the error while running http://127.0.0.1:5000/predict/ URL.



Error:



* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [02/Jan/2019 11:36:14] "GET / HTTP/1.1" 404 -
NameError: name 'svmModel' is not defined
127.0.0.1 - - [02/Jan/2019 11:36:32] "GET /predict HTTP/1.1" 500 -


I have some addresses and what to predict city ID through my model. My Model is working fine.



Updated Error:



An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

D:CondaConda_installlibsite-packagesIPythoncoreinteractiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


Edit 1



http://127.0.0.1:5000/predict?property_address=<address> I am getting only one address output but I want to post all address prediction on Browser.



for Example:



@app.route('/predict', methods=['GET'])
def predict():
property_address = request.args.get('property_address')
print (property_address)
# Get values from browser
input_data = "SELECT Detail_ID,PROPERTY_ADD + ', ' + MAIN_LOCALITY + ', ' + CITY AS PROPERTY_ADDRESS FROM NHB.DBO.HFC_UNPROCESS_01JUL2018TO30SEP2018 WHERE PROPERTY_ADD is not null"
df = pd.read_sql(input_data,cnxn)
df = pd.DataFrame(df)
df.fillna({'PROPERTY_ADDRESS': 'NA'}, inplace=True)
test_data = df['PROPERTY_ADDRESS'].values.tolist()

for i in range(0, 5):
#print (test_data[i])
class_prediced = svmModel.predict(test_data)[0]
output = "Predicted City ID: " + str(class_prediced)
#print (output)
return (output)


Here, I used for loop to get multiple outputs.



Inputs:



['Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India',
'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India',
'Goregaon East, Mumbai, Maharashtra, India']`


Expected Output:



On Browser:



'Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India'
Predicted City ID: 1

'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1

'Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1


Please suggest










share|improve this question




















  • 1





    I think you've accidentally pasted the question again instead of the error message

    – Nick Perkins
    Jan 2 at 6:04











  • Change it to this @app.route('/predict', methods=['GET'])

    – P.hunter
    Jan 2 at 6:04













  • @P.hunter the @app.route() by default just listens for GET

    – GeekSambhu
    Jan 2 at 6:13






  • 1





    You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

    – Klaus D.
    Jan 2 at 6:25
















-2















I am trying to make a API for my SVM model to predict the data through API.



I have tried below code but getting the error while running http://127.0.0.1:5000/predict/ URL.



Error:



* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [02/Jan/2019 11:36:14] "GET / HTTP/1.1" 404 -
NameError: name 'svmModel' is not defined
127.0.0.1 - - [02/Jan/2019 11:36:32] "GET /predict HTTP/1.1" 500 -


I have some addresses and what to predict city ID through my model. My Model is working fine.



Updated Error:



An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

D:CondaConda_installlibsite-packagesIPythoncoreinteractiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


Edit 1



http://127.0.0.1:5000/predict?property_address=<address> I am getting only one address output but I want to post all address prediction on Browser.



for Example:



@app.route('/predict', methods=['GET'])
def predict():
property_address = request.args.get('property_address')
print (property_address)
# Get values from browser
input_data = "SELECT Detail_ID,PROPERTY_ADD + ', ' + MAIN_LOCALITY + ', ' + CITY AS PROPERTY_ADDRESS FROM NHB.DBO.HFC_UNPROCESS_01JUL2018TO30SEP2018 WHERE PROPERTY_ADD is not null"
df = pd.read_sql(input_data,cnxn)
df = pd.DataFrame(df)
df.fillna({'PROPERTY_ADDRESS': 'NA'}, inplace=True)
test_data = df['PROPERTY_ADDRESS'].values.tolist()

for i in range(0, 5):
#print (test_data[i])
class_prediced = svmModel.predict(test_data)[0]
output = "Predicted City ID: " + str(class_prediced)
#print (output)
return (output)


Here, I used for loop to get multiple outputs.



Inputs:



['Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India',
'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India',
'Goregaon East, Mumbai, Maharashtra, India']`


Expected Output:



On Browser:



'Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India'
Predicted City ID: 1

'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1

'Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1


Please suggest










share|improve this question




















  • 1





    I think you've accidentally pasted the question again instead of the error message

    – Nick Perkins
    Jan 2 at 6:04











  • Change it to this @app.route('/predict', methods=['GET'])

    – P.hunter
    Jan 2 at 6:04













  • @P.hunter the @app.route() by default just listens for GET

    – GeekSambhu
    Jan 2 at 6:13






  • 1





    You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

    – Klaus D.
    Jan 2 at 6:25














-2












-2








-2








I am trying to make a API for my SVM model to predict the data through API.



I have tried below code but getting the error while running http://127.0.0.1:5000/predict/ URL.



Error:



* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [02/Jan/2019 11:36:14] "GET / HTTP/1.1" 404 -
NameError: name 'svmModel' is not defined
127.0.0.1 - - [02/Jan/2019 11:36:32] "GET /predict HTTP/1.1" 500 -


I have some addresses and what to predict city ID through my model. My Model is working fine.



Updated Error:



An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

D:CondaConda_installlibsite-packagesIPythoncoreinteractiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


Edit 1



http://127.0.0.1:5000/predict?property_address=<address> I am getting only one address output but I want to post all address prediction on Browser.



for Example:



@app.route('/predict', methods=['GET'])
def predict():
property_address = request.args.get('property_address')
print (property_address)
# Get values from browser
input_data = "SELECT Detail_ID,PROPERTY_ADD + ', ' + MAIN_LOCALITY + ', ' + CITY AS PROPERTY_ADDRESS FROM NHB.DBO.HFC_UNPROCESS_01JUL2018TO30SEP2018 WHERE PROPERTY_ADD is not null"
df = pd.read_sql(input_data,cnxn)
df = pd.DataFrame(df)
df.fillna({'PROPERTY_ADDRESS': 'NA'}, inplace=True)
test_data = df['PROPERTY_ADDRESS'].values.tolist()

for i in range(0, 5):
#print (test_data[i])
class_prediced = svmModel.predict(test_data)[0]
output = "Predicted City ID: " + str(class_prediced)
#print (output)
return (output)


Here, I used for loop to get multiple outputs.



Inputs:



['Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India',
'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India',
'Goregaon East, Mumbai, Maharashtra, India']`


Expected Output:



On Browser:



'Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India'
Predicted City ID: 1

'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1

'Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1


Please suggest










share|improve this question
















I am trying to make a API for my SVM model to predict the data through API.



I have tried below code but getting the error while running http://127.0.0.1:5000/predict/ URL.



Error:



* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [02/Jan/2019 11:36:14] "GET / HTTP/1.1" 404 -
NameError: name 'svmModel' is not defined
127.0.0.1 - - [02/Jan/2019 11:36:32] "GET /predict HTTP/1.1" 500 -


I have some addresses and what to predict city ID through my model. My Model is working fine.



Updated Error:



An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

D:CondaConda_installlibsite-packagesIPythoncoreinteractiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


Edit 1



http://127.0.0.1:5000/predict?property_address=<address> I am getting only one address output but I want to post all address prediction on Browser.



for Example:



@app.route('/predict', methods=['GET'])
def predict():
property_address = request.args.get('property_address')
print (property_address)
# Get values from browser
input_data = "SELECT Detail_ID,PROPERTY_ADD + ', ' + MAIN_LOCALITY + ', ' + CITY AS PROPERTY_ADDRESS FROM NHB.DBO.HFC_UNPROCESS_01JUL2018TO30SEP2018 WHERE PROPERTY_ADD is not null"
df = pd.read_sql(input_data,cnxn)
df = pd.DataFrame(df)
df.fillna({'PROPERTY_ADDRESS': 'NA'}, inplace=True)
test_data = df['PROPERTY_ADDRESS'].values.tolist()

for i in range(0, 5):
#print (test_data[i])
class_prediced = svmModel.predict(test_data)[0]
output = "Predicted City ID: " + str(class_prediced)
#print (output)
return (output)


Here, I used for loop to get multiple outputs.



Inputs:



['Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India',
'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India',
'Goregaon East, Mumbai, Maharashtra, India']`


Expected Output:



On Browser:



'Cabin K-1, Laxmi Rd, Aarey Colony, Goregaon East, Mumbai, Maharashtra 400065, India'
Predicted City ID: 1

'Aarey Colony, Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1

'Goregaon East, Mumbai, Maharashtra, India'
Predicted City ID: 1


Please suggest







python python-3.x flask






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 6:27









GeekSambhu

699819




699819










asked Jan 2 at 5:59









user10600066user10600066

135




135








  • 1





    I think you've accidentally pasted the question again instead of the error message

    – Nick Perkins
    Jan 2 at 6:04











  • Change it to this @app.route('/predict', methods=['GET'])

    – P.hunter
    Jan 2 at 6:04













  • @P.hunter the @app.route() by default just listens for GET

    – GeekSambhu
    Jan 2 at 6:13






  • 1





    You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

    – Klaus D.
    Jan 2 at 6:25














  • 1





    I think you've accidentally pasted the question again instead of the error message

    – Nick Perkins
    Jan 2 at 6:04











  • Change it to this @app.route('/predict', methods=['GET'])

    – P.hunter
    Jan 2 at 6:04













  • @P.hunter the @app.route() by default just listens for GET

    – GeekSambhu
    Jan 2 at 6:13






  • 1





    You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

    – Klaus D.
    Jan 2 at 6:25








1




1





I think you've accidentally pasted the question again instead of the error message

– Nick Perkins
Jan 2 at 6:04





I think you've accidentally pasted the question again instead of the error message

– Nick Perkins
Jan 2 at 6:04













Change it to this @app.route('/predict', methods=['GET'])

– P.hunter
Jan 2 at 6:04







Change it to this @app.route('/predict', methods=['GET'])

– P.hunter
Jan 2 at 6:04















@P.hunter the @app.route() by default just listens for GET

– GeekSambhu
Jan 2 at 6:13





@P.hunter the @app.route() by default just listens for GET

– GeekSambhu
Jan 2 at 6:13




1




1





You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

– Klaus D.
Jan 2 at 6:25





You should not use the global keyword in Python and especially not in web frameworks like Flask. In your case it does not even make any sense to globalize the open and later closed file.

– Klaus D.
Jan 2 at 6:25












2 Answers
2






active

oldest

votes


















1














Since you are expecting property_address as request argument,



property_address = request.args.get('property_address')


Requesting this as a URL will probably save you from the error :



http://127.0.0.1:5000/predict?property_address=<address>


Your custom property_address to get your desired output.






share|improve this answer


























  • getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:11











  • @user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

    – GeekSambhu
    Jan 2 at 6:16











  • Request the URL with your desired value as property address

    – GeekSambhu
    Jan 2 at 6:16











  • property address I am fetching from sql server, so there are multiple addresses

    – user10600066
    Jan 2 at 6:19






  • 1





    Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

    – user10600066
    Jan 3 at 5:19



















0














You've used svmModel instead of svmIrisModel, which is the global variable, in this line



class_prediced = svmModel.predict(test_data)[0]






share|improve this answer
























  • yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:17











  • @user10600066 Just post the server side error for easier debugging

    – GeekSambhu
    Jan 2 at 6:18











  • @user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

    – Nick Perkins
    Jan 2 at 6:19













  • I have updated my server error

    – user10600066
    Jan 2 at 9:30











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001882%2fhow-to-make-api-by-using-flask-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Since you are expecting property_address as request argument,



property_address = request.args.get('property_address')


Requesting this as a URL will probably save you from the error :



http://127.0.0.1:5000/predict?property_address=<address>


Your custom property_address to get your desired output.






share|improve this answer


























  • getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:11











  • @user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

    – GeekSambhu
    Jan 2 at 6:16











  • Request the URL with your desired value as property address

    – GeekSambhu
    Jan 2 at 6:16











  • property address I am fetching from sql server, so there are multiple addresses

    – user10600066
    Jan 2 at 6:19






  • 1





    Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

    – user10600066
    Jan 3 at 5:19
















1














Since you are expecting property_address as request argument,



property_address = request.args.get('property_address')


Requesting this as a URL will probably save you from the error :



http://127.0.0.1:5000/predict?property_address=<address>


Your custom property_address to get your desired output.






share|improve this answer


























  • getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:11











  • @user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

    – GeekSambhu
    Jan 2 at 6:16











  • Request the URL with your desired value as property address

    – GeekSambhu
    Jan 2 at 6:16











  • property address I am fetching from sql server, so there are multiple addresses

    – user10600066
    Jan 2 at 6:19






  • 1





    Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

    – user10600066
    Jan 3 at 5:19














1












1








1







Since you are expecting property_address as request argument,



property_address = request.args.get('property_address')


Requesting this as a URL will probably save you from the error :



http://127.0.0.1:5000/predict?property_address=<address>


Your custom property_address to get your desired output.






share|improve this answer















Since you are expecting property_address as request argument,



property_address = request.args.get('property_address')


Requesting this as a URL will probably save you from the error :



http://127.0.0.1:5000/predict?property_address=<address>


Your custom property_address to get your desired output.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 2 at 6:14

























answered Jan 2 at 6:09









GeekSambhuGeekSambhu

699819




699819













  • getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:11











  • @user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

    – GeekSambhu
    Jan 2 at 6:16











  • Request the URL with your desired value as property address

    – GeekSambhu
    Jan 2 at 6:16











  • property address I am fetching from sql server, so there are multiple addresses

    – user10600066
    Jan 2 at 6:19






  • 1





    Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

    – user10600066
    Jan 3 at 5:19



















  • getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:11











  • @user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

    – GeekSambhu
    Jan 2 at 6:16











  • Request the URL with your desired value as property address

    – GeekSambhu
    Jan 2 at 6:16











  • property address I am fetching from sql server, so there are multiple addresses

    – user10600066
    Jan 2 at 6:19






  • 1





    Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

    – user10600066
    Jan 3 at 5:19

















getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

– user10600066
Jan 2 at 6:11





getting error: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:40:34] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

– user10600066
Jan 2 at 6:11













@user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

– GeekSambhu
Jan 2 at 6:16





@user10600066 what is your expected value in property_address? this must be some value, other than the default <address> because this is just a template value. It can be http://127.0.0.1:5000/predict?property_address=123 or http://127.0.0.1:5000/predict?property_address=345 etc

– GeekSambhu
Jan 2 at 6:16













Request the URL with your desired value as property address

– GeekSambhu
Jan 2 at 6:16





Request the URL with your desired value as property address

– GeekSambhu
Jan 2 at 6:16













property address I am fetching from sql server, so there are multiple addresses

– user10600066
Jan 2 at 6:19





property address I am fetching from sql server, so there are multiple addresses

– user10600066
Jan 2 at 6:19




1




1





Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

– user10600066
Jan 3 at 5:19





Yes, I did this process but unable to return the list but Now I am able to return all values by using this: class_prediced = svmModel.predict(test_data)

– user10600066
Jan 3 at 5:19













0














You've used svmModel instead of svmIrisModel, which is the global variable, in this line



class_prediced = svmModel.predict(test_data)[0]






share|improve this answer
























  • yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:17











  • @user10600066 Just post the server side error for easier debugging

    – GeekSambhu
    Jan 2 at 6:18











  • @user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

    – Nick Perkins
    Jan 2 at 6:19













  • I have updated my server error

    – user10600066
    Jan 2 at 9:30
















0














You've used svmModel instead of svmIrisModel, which is the global variable, in this line



class_prediced = svmModel.predict(test_data)[0]






share|improve this answer
























  • yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:17











  • @user10600066 Just post the server side error for easier debugging

    – GeekSambhu
    Jan 2 at 6:18











  • @user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

    – Nick Perkins
    Jan 2 at 6:19













  • I have updated my server error

    – user10600066
    Jan 2 at 9:30














0












0








0







You've used svmModel instead of svmIrisModel, which is the global variable, in this line



class_prediced = svmModel.predict(test_data)[0]






share|improve this answer













You've used svmModel instead of svmIrisModel, which is the global variable, in this line



class_prediced = svmModel.predict(test_data)[0]







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 6:14









Nick PerkinsNick Perkins

1,13321124




1,13321124













  • yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:17











  • @user10600066 Just post the server side error for easier debugging

    – GeekSambhu
    Jan 2 at 6:18











  • @user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

    – Nick Perkins
    Jan 2 at 6:19













  • I have updated my server error

    – user10600066
    Jan 2 at 9:30



















  • yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

    – user10600066
    Jan 2 at 6:17











  • @user10600066 Just post the server side error for easier debugging

    – GeekSambhu
    Jan 2 at 6:18











  • @user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

    – Nick Perkins
    Jan 2 at 6:19













  • I have updated my server error

    – user10600066
    Jan 2 at 9:30

















yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

– user10600066
Jan 2 at 6:17





yes, it was type error but still getting error on browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. and in spyder console: NameError: name 'svmModel' is not defined 127.0.0.1 - - [02/Jan/2019 11:45:13] "GET /predict?property_address=%3Caddress%3E HTTP/1.1" 500 -

– user10600066
Jan 2 at 6:17













@user10600066 Just post the server side error for easier debugging

– GeekSambhu
Jan 2 at 6:18





@user10600066 Just post the server side error for easier debugging

– GeekSambhu
Jan 2 at 6:18













@user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

– Nick Perkins
Jan 2 at 6:19







@user10600066 Your new code doesn't make sense as you've just changed the global variable name. The data is loaded into a variable inaccessible by the predict function.

– Nick Perkins
Jan 2 at 6:19















I have updated my server error

– user10600066
Jan 2 at 9:30





I have updated my server error

– user10600066
Jan 2 at 9:30


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001882%2fhow-to-make-api-by-using-flask-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

Npm cannot find a required file even through it is in the searched directory