Method Not Allowed The method is not allowed for the requested URl showing error
Following code trying to upload json data into MySQL database but showing error like "Method Not Allowed The method is not allowed for the requested URL." Not uploaded json data into MySQL dabase. Please help me what exact problem in my code. I'm new user using flask. After run code I got above error.
from __future__ import print_function
from flask import Flask, request, jsonify, render_template
from werkzeug import secure_filename
from flask_cors import CORS
from random import randint
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
import MySQLdb
import json
a= [{"JD_Name": "Data Engineer","ID":10,"No_of_Position":5,"Skill_Sets":"Big Data, Python, Hadoop, MapReduce", "Created_Date":"2018-06-30","Received_profile":25,"Interview_completed":4,"Yet_to_schedule":10,
"Attachments":"https://s1.amazon.com/jd-upload/DataJD.docx"}]
app = flask.Flask(__name__)
CORS(app)
app.config["DEBUG"] = True
# do validation and checks before insert
def validate_string(val):
if val != None:
if type(val) is int:
#for x in val:
# print(x)
return str(val).encode('utf-8')
else:
return val
@app.route("/uploaddata", methods=['POST'])
def upload_file():
db = MySQLdb.connect("localhost", "root", "Mysql1!","test")
cur = db.cursor()
for i, item in enumerate(a):
JD_Name= validate_string(item.get("JD_Name", None))
ID= validate_string(item.get("ID", None))
No_of_Position= validate_string(item.get("No_of_Position", None))
Skill_Sets= validate_string(item.get("Skill_Sets", None))
Created_Date= validate_string(item.get("Created_Date", None))
Received_profile= validate_string(item.get("Received_profile", None))
Interview_completed= validate_string(item.get("Interview_completed", None))
Yet_to_schedule= validate_string(item.get("Yet_to_schedule", None))
Attachments= validate_string(item.get("Attachments", None))
cursor.execute("INSERT INTO addjd1 (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments))
con.commit()
con.close()
return 'file uploaded successfully'
app.run()
python mysql flask
add a comment |
Following code trying to upload json data into MySQL database but showing error like "Method Not Allowed The method is not allowed for the requested URL." Not uploaded json data into MySQL dabase. Please help me what exact problem in my code. I'm new user using flask. After run code I got above error.
from __future__ import print_function
from flask import Flask, request, jsonify, render_template
from werkzeug import secure_filename
from flask_cors import CORS
from random import randint
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
import MySQLdb
import json
a= [{"JD_Name": "Data Engineer","ID":10,"No_of_Position":5,"Skill_Sets":"Big Data, Python, Hadoop, MapReduce", "Created_Date":"2018-06-30","Received_profile":25,"Interview_completed":4,"Yet_to_schedule":10,
"Attachments":"https://s1.amazon.com/jd-upload/DataJD.docx"}]
app = flask.Flask(__name__)
CORS(app)
app.config["DEBUG"] = True
# do validation and checks before insert
def validate_string(val):
if val != None:
if type(val) is int:
#for x in val:
# print(x)
return str(val).encode('utf-8')
else:
return val
@app.route("/uploaddata", methods=['POST'])
def upload_file():
db = MySQLdb.connect("localhost", "root", "Mysql1!","test")
cur = db.cursor()
for i, item in enumerate(a):
JD_Name= validate_string(item.get("JD_Name", None))
ID= validate_string(item.get("ID", None))
No_of_Position= validate_string(item.get("No_of_Position", None))
Skill_Sets= validate_string(item.get("Skill_Sets", None))
Created_Date= validate_string(item.get("Created_Date", None))
Received_profile= validate_string(item.get("Received_profile", None))
Interview_completed= validate_string(item.get("Interview_completed", None))
Yet_to_schedule= validate_string(item.get("Yet_to_schedule", None))
Attachments= validate_string(item.get("Attachments", None))
cursor.execute("INSERT INTO addjd1 (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments))
con.commit()
con.close()
return 'file uploaded successfully'
app.run()
python mysql flask
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
Welcome to Stackoverflow. If you try to browse/uploaddata
it performs aGET
request which is not listed inmethods
list. APOST
request can be perform by adding/uploaddata
in a form action's attribute.
– arsho
Nov 19 '18 at 10:14
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19
add a comment |
Following code trying to upload json data into MySQL database but showing error like "Method Not Allowed The method is not allowed for the requested URL." Not uploaded json data into MySQL dabase. Please help me what exact problem in my code. I'm new user using flask. After run code I got above error.
from __future__ import print_function
from flask import Flask, request, jsonify, render_template
from werkzeug import secure_filename
from flask_cors import CORS
from random import randint
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
import MySQLdb
import json
a= [{"JD_Name": "Data Engineer","ID":10,"No_of_Position":5,"Skill_Sets":"Big Data, Python, Hadoop, MapReduce", "Created_Date":"2018-06-30","Received_profile":25,"Interview_completed":4,"Yet_to_schedule":10,
"Attachments":"https://s1.amazon.com/jd-upload/DataJD.docx"}]
app = flask.Flask(__name__)
CORS(app)
app.config["DEBUG"] = True
# do validation and checks before insert
def validate_string(val):
if val != None:
if type(val) is int:
#for x in val:
# print(x)
return str(val).encode('utf-8')
else:
return val
@app.route("/uploaddata", methods=['POST'])
def upload_file():
db = MySQLdb.connect("localhost", "root", "Mysql1!","test")
cur = db.cursor()
for i, item in enumerate(a):
JD_Name= validate_string(item.get("JD_Name", None))
ID= validate_string(item.get("ID", None))
No_of_Position= validate_string(item.get("No_of_Position", None))
Skill_Sets= validate_string(item.get("Skill_Sets", None))
Created_Date= validate_string(item.get("Created_Date", None))
Received_profile= validate_string(item.get("Received_profile", None))
Interview_completed= validate_string(item.get("Interview_completed", None))
Yet_to_schedule= validate_string(item.get("Yet_to_schedule", None))
Attachments= validate_string(item.get("Attachments", None))
cursor.execute("INSERT INTO addjd1 (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments))
con.commit()
con.close()
return 'file uploaded successfully'
app.run()
python mysql flask
Following code trying to upload json data into MySQL database but showing error like "Method Not Allowed The method is not allowed for the requested URL." Not uploaded json data into MySQL dabase. Please help me what exact problem in my code. I'm new user using flask. After run code I got above error.
from __future__ import print_function
from flask import Flask, request, jsonify, render_template
from werkzeug import secure_filename
from flask_cors import CORS
from random import randint
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
import MySQLdb
import json
a= [{"JD_Name": "Data Engineer","ID":10,"No_of_Position":5,"Skill_Sets":"Big Data, Python, Hadoop, MapReduce", "Created_Date":"2018-06-30","Received_profile":25,"Interview_completed":4,"Yet_to_schedule":10,
"Attachments":"https://s1.amazon.com/jd-upload/DataJD.docx"}]
app = flask.Flask(__name__)
CORS(app)
app.config["DEBUG"] = True
# do validation and checks before insert
def validate_string(val):
if val != None:
if type(val) is int:
#for x in val:
# print(x)
return str(val).encode('utf-8')
else:
return val
@app.route("/uploaddata", methods=['POST'])
def upload_file():
db = MySQLdb.connect("localhost", "root", "Mysql1!","test")
cur = db.cursor()
for i, item in enumerate(a):
JD_Name= validate_string(item.get("JD_Name", None))
ID= validate_string(item.get("ID", None))
No_of_Position= validate_string(item.get("No_of_Position", None))
Skill_Sets= validate_string(item.get("Skill_Sets", None))
Created_Date= validate_string(item.get("Created_Date", None))
Received_profile= validate_string(item.get("Received_profile", None))
Interview_completed= validate_string(item.get("Interview_completed", None))
Yet_to_schedule= validate_string(item.get("Yet_to_schedule", None))
Attachments= validate_string(item.get("Attachments", None))
cursor.execute("INSERT INTO addjd1 (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", (JD_Name, ID, No_of_Position, Skill_Sets, Created_Date, Received_profile, Interview_completed, Yet_to_schedule, Attachments))
con.commit()
con.close()
return 'file uploaded successfully'
app.run()
python mysql flask
python mysql flask
edited Nov 19 '18 at 10:04
Poonam K
asked Nov 19 '18 at 9:58
Poonam KPoonam K
11
11
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
Welcome to Stackoverflow. If you try to browse/uploaddata
it performs aGET
request which is not listed inmethods
list. APOST
request can be perform by adding/uploaddata
in a form action's attribute.
– arsho
Nov 19 '18 at 10:14
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19
add a comment |
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
Welcome to Stackoverflow. If you try to browse/uploaddata
it performs aGET
request which is not listed inmethods
list. APOST
request can be perform by adding/uploaddata
in a form action's attribute.
– arsho
Nov 19 '18 at 10:14
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
Welcome to Stackoverflow. If you try to browse
/uploaddata
it performs a GET
request which is not listed in methods
list. A POST
request can be perform by adding /uploaddata
in a form action's attribute.– arsho
Nov 19 '18 at 10:14
Welcome to Stackoverflow. If you try to browse
/uploaddata
it performs a GET
request which is not listed in methods
list. A POST
request can be perform by adding /uploaddata
in a form action's attribute.– arsho
Nov 19 '18 at 10:14
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19
add a comment |
0
active
oldest
votes
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372155%2fmethod-not-allowed-the-method-is-not-allowed-for-the-requested-url-showing-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372155%2fmethod-not-allowed-the-method-is-not-allowed-for-the-requested-url-showing-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
This doesn't seem to have anything to do with mysql, but with your Flask route. How did you call it? Did you actually make a POST request?
– Daniel Roseman
Nov 19 '18 at 10:09
Welcome to Stackoverflow. If you try to browse
/uploaddata
it performs aGET
request which is not listed inmethods
list. APOST
request can be perform by adding/uploaddata
in a form action's attribute.– arsho
Nov 19 '18 at 10:14
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
Nov 20 '18 at 6:19