From 6724159cd2436c18c795b4a72d4037bc762b0566 Mon Sep 17 00:00:00 2001 From: ethanc <17chiue@gmail.com> Date: Sun, 14 Oct 2018 22:10:33 -0700 Subject: [PATCH] Fix run AJAX call to POST correctly --- app.py | 2 +- static/js/javascript.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 21dd52fa..a57546eb 100644 --- a/app.py +++ b/app.py @@ -64,7 +64,7 @@ def check_code(): return jsonify(output) # Run python in secure system -@app.route('/run_code') +@app.route('/run_code', methods=['POST']) def run_code(): """Run python 3 code :return: JSON object of python 3 output diff --git a/static/js/javascript.js b/static/js/javascript.js index dfc0596d..2b1a07b7 100644 --- a/static/js/javascript.js +++ b/static/js/javascript.js @@ -114,18 +114,18 @@ $(document).ready(function(){ //Actually Run in Python $( "#run" ).click(function() { - $.post('/run_code', { + $.post('/run_code', { text : editor.getValue() }, function(data) { print_result(data); return false; - }); + }, 'json'); function print_result(data){ document.getElementById('output').innerHTML = ''; $("#output").append("
"+data+""); } - }, "json"); + }); var exampleCode = function (id, text) { $(id).click(function (e) { editor.setValue(text);