##やろうとしていること
LINE BOTアプリの動作確認を行うため、ngrokを使用してURLを取得したい。
##試したこと
ngrokをラズベリーパイにインストールし、次のコマンドを実行しました。
**$ ngrok http 5000
その時の画面は、次の通りでした。
text
1ngrok by @inconshreveable (Ctrl+C to quit) 2 3Session Status reconnecting (Get https://dns.google.com/resolve?cd=true&name=tunnel.us.ngrok.com&type=AAAA: dial tcp 8.8.4.4:443: connect: ne 4Version 2.3.35 5Region United States (us) 6Web Interface http://127.0.0.1:4040 7 8Connections ttl opn rt1 rt5 p50 p90 9 0 0 0.00 0.00 0.00 0.00 10
text
1ngrok by @inconshreveable (Ctrl+C to quit) 2 3Session Status reconnecting (dial tcp 3.15.55.144:443: connect: network is unreachable) 4Version 2.3.35 5Region United States (us) 6Web Interface http://127.0.0.1:4040 7 8Connections ttl opn rt1 rt5 p50 p90 9 0 0 0.00 0.00 0.00 0.00
##NW環境
Mobile WiFiルータに接続しています。
Windows PCから、Raspberry PiにSSH接続して、開発しています。
Windows PCも同じMobile WiFiルータに接続しています。
##プログラム
こちらはあまり問題と関係ないかもしれませんが、LINE Botのプログラムを掲載させていただきます。
python
1# -*- coding: utf-8 -*- 2 3from flask import Flask, request, abort 4 5from linebot import ( 6 LineBotApi, WebhookHandler 7) 8from linebot.exceptions import ( 9 InvalidSignatureError 10) 11from linebot.models import ( 12 MessageEvent, TextMessage, TextSendMessage, 13) 14 15app = Flask(__name__) 16 17line_bot_api = LineBotApi('hogehoge_token') 18handler = WebhookHandler('hogehoge_secret') 19 20@app.route("/") 21def hello_world(): 22 return "hello world!" 23 24@app.route("/callback", methods=['POST']) 25def callback(): 26 # get X-Line-Signature header value 27 signature = request.headers['X-Line-Signature'] 28 29 # get request body as text 30 body = request.get_data(as_text=True) 31 app.logger.info("Request body: " + body) 32 33 # handle webhook body 34 try: 35 handler.handle(body, signature) 36 except InvalidSignatureError: 37 abort(400) 38 39 return 'OK' 40 41 42@handler.add(MessageEvent, message=TextMessage) 43def handle_message(event): 44 line_bot_api.reply_message( 45 event.reply_token, 46 TextSendMessage(text=event.message.text)) 47 48 49if __name__ == "__main__": 50 app.run()
回答1件
あなたの回答
tips
プレビュー