Hi guys, So don't know if I'm completely missing out here, but I just can't seem to be able to figure out how to run other python scripts from Flask.
E.g. what I want: from flask import Flask app = Flask(__name__) @app.route("/some_script") def script1(): #./some_script.py # e.g. I want to make flask run some_script.py, which is in the same directory as my flask.py file on a server def script2(): #./some_other_script.py # e.g. same thing The scripts are a one-of: e.g. they don't need to run as a service, or sub-thread or anything. They just query a server, treat the response & update a (local) database. ============ Background as to the why of this: Basically, I'm using D3 and I'm trying to fetch data from a server that doesn't support CORS. So basically I can't access the data through JS. Since already have python scripts (some_script & some_other_script.py) which are able to retrieve the data that I want and treat it, I figure I would use Flask in the following way: - The user hits a refresh button or selects new data they want to display on the dashboard webpage - In my JS/D3 code, this makes a call to localhost::5000/some_script, so the corresponding route for flask - Flask then runs the python script accordingly, which fetches the data (and doesn't need to worry about same-origin policy because it's done from the server, not the browser), and treats it. This updates the database that actually feeds D3. - flask.py returns some ok/error message to D3. D3 now knows the database has been updated and can display the updated data. The current setup is not great and has me running the python script as a cronjob periodically, which is ineffecient (why update my database if no one is looking at it, needless traffic on the server, eg). I first tried to have the import &everything done through D3, but ran into the same-origin policy (basically your browser cannot request directly data from another domain, has to be done through the server... or if the target server support CORS, but my target doesn't). Also I don't want to loose all the working python scripts that already does authentication & fetching & pre-treatment for me, likely much better than JS is likely to be able to do. There are some other options around this, such as a PHP proxy (but I don't know PHP and really want to add it here for that sole purpose) or JSONP, but JSONP is kind flawed. If you have fundamentally better approach I am open, but as far as I can see the above would do a decent job. Thanks, -- You received this message because you are subscribed to the Google Groups "pocoo-libs" group. To unsubscribe from this group and stop receiving emails from it, send an email to pocoo-libs+unsubscr...@googlegroups.com. To post to this group, send email to pocoo-libs@googlegroups.com. Visit this group at https://groups.google.com/group/pocoo-libs. For more options, visit https://groups.google.com/d/optout.