import os from bot import app if __name__ == "__main__": # app.run() port = int(os.getenv("PORT", 5000)) app.run(host="0.0.0.0", port=port)
if retrieveContext(chat_id, from_user): context0 = retrieveContext(chat_id, from_user) context0['platform'] = 'FB' if msg_obj.get('message') and msg_obj['message'].get( 'attachments'): img_url = msg_obj['message'].get( 'attachments')[0]['payload']['url'] context0['user_img_url'] = img_url context0['search_type'] = 'image' storeContext(chat_id, from_user, context0) doSearchEncounter(chat_id, context0) elif msg_obj.get('message') and msg_obj['message'].get('text'): msg = msg_obj['message']['text'] storeContext(chat_id, from_user, context0, msg=msg) selectActionFromText(chat_id, from_user, msg, context0) elif msg_obj.get('postback') and msg_obj['postback'].get( 'payload'): msg = msg_obj['postback'].get('payload') storeContext(chat_id, from_user, context0, msg=msg) print msg selectActionFromText(chat_id, from_user, msg, context0) else: continue return Response(status=200) return Response(status=200) if __name__ == "__main__": application.run()
from bot import app from bot import routes if __name__ == "__main__": app.run()
from bot import app app.run(debug=True)
from_user = msg_obj['sender']['id'] chat_id = from_user context0 = {'from_user':from_user,'chat_id':chat_id} if retrieveContext(chat_id,from_user): context0 = retrieveContext(chat_id,from_user) context0['platform'] = 'FB' if msg_obj.get('message') and msg_obj['message'].get('attachments'): img_url = msg_obj['message'].get('attachments')[0]['payload']['url'] context0['user_img_url'] = img_url context0['search_type'] = 'image' storeContext(chat_id,from_user,context0) doSearchEncounter(chat_id, context0) elif msg_obj.get('message') and msg_obj['message'].get('text'): msg = msg_obj['message']['text'] storeContext(chat_id,from_user,context0,msg=msg) selectActionFromText(chat_id,from_user, msg,context0) elif msg_obj.get('postback')and msg_obj['postback'].get('payload'): msg = msg_obj['postback'].get('payload') storeContext(chat_id,from_user,context0,msg=msg) print msg selectActionFromText(chat_id,from_user, msg,context0) else: continue return Response(status=200) return Response(status=200) if __name__ == "__main__": application.run()
from threading import Thread from bot import app, sound_queue from bot.mumble import MumbleBot mumble_bot = MumbleBot(sound_queue, app) t1 = Thread(target=mumble_bot.run) t1.start() serverThreading = Thread(target=app.run(host="0.0.0.0", debug=True)) serverThreading.start()
from bot import app from telegram import Bot from plugin import Plugin if __name__ == "__main__": commands = [instance.name for plugin,instance in Plugin.plugins.items() if instance.command] print commands bot = Bot(app.config.get('TOKEN')) bot.setWebhook(app.config.get('WEBHOOK')) app.run(debug=True, port=80, host="0.0.0.0")
from bot import app if __name__ == "__main__": app.run(port=3000)
return make_response(json.dumps({"action": "reloadDatasets", "datasetNames": d}), 200, {"content_type": "application/json"}) elif data["action"] == "deleteStatistic": serv.delete_statistic(data["name"]) s = json.dumps(serv.get_statistic_names()) return make_response(json.dumps({"action": "reloadStatistics", "statisticNames": s}), 200, {"content_type": "application/json"}) elif data["action"] == "getMessages": m = json.dumps(serv.get_messages(), default=str) return make_response(json.dumps({"action": "setMessages", "messages": m}), 200, {"content_type": "application/json"}) elif data["action"] == "getLogs": l = json.dumps(serv.get_logs(), default=str) return make_response(json.dumps({"action": "setLogs", "logs": l}), 200, {"content_type": "application/json"}) return make_response("ok") else: d = json.dumps(serv.get_dataset_names()) s = json.dumps(serv.get_statistic_names()) t = json.dumps(types) return render_template(template, dataset_names=d, statistic_names=s, types=t) @auth.get_password def get_pw(username): if username == ADMIN: return PASSWORD return None if __name__ == '__main__': port = int(os.getenv('PORT', 5000)) # For Heroku, in another way can be used APPPORT app.run(debug=bool(DEBUG), port=port, host=APPHOST)
#!/bin/python # -*- coding: utf-8 -*- from bot import app # Импортируем наше приложение if __name__ == "__main__": app.run() # запускаем его
import os from bot import app if __name__ == '__main__': # Bind to PORT if defined, otherwise default to 5000. port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port)