-1

I am new to Flask, and have a very basic website up.

The goal is to create a program (run locally) that streams tweets from specific users. A button next to the post - if clicked it will favorite the tweet.

I have scripts for favoriting tweets and streaming twitter posts.

Is there a way to call these scripts by the push of a button on the flask-based site?

1 Answer 1

2

If the scripts are python scripts, you can just import those scripts into your flask app. Then, call the functions you need (favoriting tweets for example) from within a flask route (the route that is triggered when the user clicks the button, for example).

If the scripts aren't python scripts, they probably should be. In this case though you can look at using the subprocess module to call external programs. Once again, you'll want to put the subprocess call inside the flask route that is triggered upon button press. So if your button triggers the flask route /favorite, put the code calling the scripts inside that route's flask declaration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.