I am experimenting with Flask and AJAX, I have a simple API route here , hosted at OpenShift. I want to call the API in a Javascript file with Ajax. The OpenShift Python file is simple:
from flask import Flask app = Flask(__name__) import json @app.route('/hello/<name>') def hello_world(name=None): str = {'key':'Hello World!', 'q':name} #out = {'key':str} res = json.dumps(str) return res if __name__ == '__main__': app.run() And here is the Ajax call:
$.ajax({ type:"GET", dataType: "json", data:'Payam', url: "http://mypythonapp-spacepirate.rhcloud.com/hello/", success: function(data){ buf1=data; console.log(data); } }) But this makes a call to this url which results in 404. How can I solve this? Just to mention CORS is not an issue.
http://mypythonapp-spacepirate.rhcloud.com/hello/?Payam