Skip to content

Commit a11cb93

Browse files
committed
Change from GET to POST to fix 414 issue
1 parent 3e5c7f3 commit a11cb93

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def index():
3434
session["time_now"] = datetime.now()
3535
return render_template("index.html")
3636

37-
@app.route('/check_code')
37+
@app.route('/check_code', methods=['POST'])
3838
def check_code():
3939
"""Run pylint on code and get output
4040
:return: JSON object of pylint errors
@@ -53,7 +53,7 @@ def check_code():
5353
https://github.com/PyCQA/pylint/blob/master/pylint/lint.py
5454
"""
5555
#Get textarea text from AJAX call
56-
text = request.args.get('text')
56+
text = request.form['text']
5757

5858
# Session to handle multiple users at one time
5959
session["code"] = text

static/js/cm-validator-remote.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CodeMirror.remoteValidator = function(cm, updateLinting, options) {
1313
{
1414
var found = [];
1515

16-
console.log(error_list);
1716
for(var i in error_list)
1817
{
1918
var error = error_list[i];
@@ -53,7 +52,7 @@ CodeMirror.remoteValidator = function(cm, updateLinting, options) {
5352
});
5453
}
5554
}
56-
55+
5756
updateLinting(cm, found);
5857
}
5958

static/js/javascript.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ $(document).ready(function(){
8585

8686
}
8787
//AJAX call to pylint
88-
$.getJSON('/check_code', {
88+
$.post('/check_code', {
8989
text : code
9090
}, function(data) {
9191
current_text = data;
@@ -114,7 +114,7 @@ $(document).ready(function(){
114114

115115
//Actually Run in Python
116116
$( "#run" ).click(function() {
117-
$.getJSON('/run_code', {
117+
$.post('/run_code', {
118118
text : editor.getValue()
119119
}, function(data) {
120120
print_result(data);
@@ -125,7 +125,7 @@ $(document).ready(function(){
125125
document.getElementById('output').innerHTML = '';
126126
$("#output").append("<pre>"+data+"</pre>");
127127
}
128-
});
128+
}, "json");
129129
var exampleCode = function (id, text) {
130130
$(id).click(function (e) {
131131
editor.setValue(text);

0 commit comments

Comments
 (0)