I'm building a binance trading bot. When I upload it to your Heroku server, the 'printt' function seems to be run 2-3 times. When I run it myself in the terminal, it starts once and works properly.
app = Flask(__name__)
global letter
letter = "a"
def printt():
while True:
print(letter)
@app.route("/")
def helloWorld():
return "Hello world"
@app.route("/webhook", methods=["POST"])
def webhook():
data = json.loads(request.data)
letter = data['letter']
import threading
t1 = threading.Thread(target= printt)
t1.start()
For example, when I post, I send 'b', but the program prints both 'a' and 'b'. How can I fix this?