i made viber bot on python. its working fine. now i am trying to run few bots on one webserver. the first bot is working but the second one not.
app = Flask(__name__)
app2 = Flask('app2')
@app.route('/', methods=['POST'])
def incoming():
viber_request = viber.parse_request(request.get_data())
if isinstance(viber_request, ViberMessageRequest):
viber.send_messages(viber_request.sender.id,[TextMessage(text='test1')] )
@app2.route('/ff', methods=['POST'])
def incoming2():
viber_request = viber.parse_request(request.get_data())
if isinstance(viber_request, ViberMessageRequest):
viber.send_messages(viber_request.sender.id,[TextMessage(text='test2')] )
def set_webhook(viber):
viber.unset_webhook()
time.sleep(1)
viber.set_webhook('https://myhost.pythonanywhere.com')
def set_webhook2(viber2):
viber2.unset_webhook()
time.sleep(1)
viber2.set_webhook('https://myhost.pythonanywhere.com/ff')
if __name__ == "__main__":
scheduler = sched.scheduler(time.time, time.sleep)
scheduler.enter(5, 1, set_webhook, (viber,))
t = threading.Thread(target=scheduler.run)
t.start()
scheduler = sched.scheduler(time.time, time.sleep)
scheduler.enter(5, 1, set_webhook2, (viber2,))
t = threading.Thread(target=scheduler.run)
t.start()
app.run(host='https://myhost.pythonanywhere.com', port=8443, debug=True)
app2.run(host='https://myhost.pythonanywhere.com/ff', port=8080, debug=True)
first bot responding with test1 but second one silent. how to run few bots on one webserver properly ? Both tokens are correct