Method Not Allowed The method is not allowed for the requested URl showing error
up vote
0
down vote
favorite
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
New contributor
add a comment |
up vote
0
down vote
favorite
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
New contributor
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
23 hours ago
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
23 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
New contributor
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
New contributor
New contributor
edited yesterday
New contributor
asked yesterday
Poonam K
11
11
New contributor
New contributor
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
23 hours ago
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
23 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago
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
23 hours ago
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
23 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago
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
23 hours ago
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
23 hours ago
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
23 hours ago
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
23 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Poonam K is a new contributor. Be nice, and check out our Code of Conduct.
Poonam K is a new contributor. Be nice, and check out our Code of Conduct.
Poonam K is a new contributor. Be nice, and check out our Code of Conduct.
Poonam K is a new contributor. Be nice, and check out our Code of Conduct.
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
23 hours ago
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
23 hours ago
Thanks Daniel and Arsho for looking this query. I solved this problem used a GET request.
– Poonam K
3 hours ago