I want to build a website using Flask that will allow users to control a Python bot that I recently created, for example I will want it to when you press a 'Turn on' button from the website it will create a new shell that will start running this bot, but there needs to be a different shell running for every user that turns the bot on, as there will be specific arguments (API keys) that the user will need to provide the bot.
How is this achievable in terms of running the same Python script multiple times from the website for different users and different arguments?
Thanks
CodePudding user response:
Use subprocess.Popen
to open shell and close it whenever you want
import subprocess
class bot_process:
def __init__(self, args):
self.process = subprocess.Popen("python bot.py " args)
def stop(self):
self.process.terminate()