我是新來的電報機器人的發展,我被困,同時部署項目GAE和創建網絡掛接500錯誤,同時部署電報機器人Google App Engine的
我有一個簡單的機器人,這是我從這裏拿了https://github.com/sooyhwang/Simple-Echo-Telegram-Bot:
from flask import Flask, request
import telegram
import config
import logging
bot = telegram.Bot(config.token)
app = Flask(__name__)
URL = 'my-service-dot-kristik-160312.appspot.com/'
#def sendPhotoToServer() -> Bool:
# sending photo to server
# return
@app.route('/HOOK', methods=['POST'])
def webhook_handler():
if request.method == "POST":
update = telegram.Update.de_json(request.get_json(force=True))
chat_id = update.message.chat.id
text = update.message.text.encode('utf-8')
bot.sendMessage(chat_id=chat_id, text=text)
logging.getLogger().setLevel(logging.INFO)
logging.info('===============TEXT=================')
return 'ok'
@app.route('/set_webhook', methods=['GET', 'POST'])
def set_webhook():
s = bot.setWebhook('https://my-service-dot-kristik-160312.appspot.com/HOOK')
if s:
return "webhook setup ok"
else:
return "webhook setup failed"
@app.route('/')
def index():
return 'App is ready'
當我去https://my-service-dot-kristik-160312.appspot.com/set_webhook
我得到500錯誤。
我在做什麼錯?
服務器日誌:
5.254.65.88 - - [04/Mar/2017:00:53:54 +0300] "GET /set_webhook HTTP/1.1" 500 264 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" "my-service-dot-kristik-160312.appspot.com" ms=12 cpu_ms=18 cpm_usd=2.9504e-8 loading_request=0 instance=00c61b117c22a1c62e3fac7b35862e68e42b61f0284c2de4c4f50e319bcfa0d57efafc3b4e58 app_engine_release=1.9.48 trace_id=28ae78361cb2dde6bf4f6388ba535198
00:53:54.036
Entering: setWebhook
00:53:54.040
[2017-03-03 21:53:54,039] ERROR in app: Exception on /set_webhook [GET]
00:53:54.040
Traceback (most recent call last):
00:53:54.040
File "/base/data/home/apps/e~kristik-160312/my-service:20170303t195857.399582377782761728/lib/flask/app.py", line 1982, in wsgi_app
00:53:54.040
response = self.full_dispatch_request()
00:53:54.040
File "/base/data/home/apps/e~kristik-160312/my-service:20170303t195857.399582377782761728/lib/flask/app.py", line 1614, in full_dispatch_request
00:53:54.040
rv = self.handle_user_exception(e)
00:53:54.040
File "/base/data/home/apps/e~kristik-160312/my-service:20170303t195857.399582377782761728/lib/flask/app.py", line 1517, in handle_user_exception
00:53:54.040
reraise(exc_type, exc_value, tb)
00:53:54.040
File "/base/data/home/apps/e~kristik-160312/my-service:20170303t195857.399582377782761728/lib/flask/app.py", line 1612, in full_dispatch_request
500錯誤代碼表示的東西發生在服務器端。就是這樣。您必須始終檢查應用程序的日誌以瞭解更多詳細信息。 –
@DanCornilescu我已經包含了日誌,bur,對我來說,這並沒有讓任何事情變得很清楚,不幸的是 – dand1
好吧,至少現在你知道這是從's = bot.setWebhook(...)'引發的異常(重新)。太糟糕的燒瓶不給更多的信息... –