I want to run a Python Flask app with a Raspberry Pi. The pi is connected through a router. Thus the Flask web app can be viewed from other devices connected to the router. However, my raspberry pi IP address is 192.168.1.145 and the app runs with this URL 192.168.1.145:5000. I would give a meaningful hostname to the raspberry pi like flaskserver:5000 and make it accessible to other devices connected to the same router as pi.
I have tried the following steps-
app.config['SERVER_NAME'] = 'flaskserver:5000' app.run(host = '192.168.1.145', port = 5000, debug=True, use_reloader=False)
app.config['SERVER_NAME'] = 'flaskserver:5000' app.run(host = 'flaskserver', port = 5000, debug=True, use_reloader=False)
I am making a lot of trial and error with the configurations. So far nothing has worked. Any advice would be appreciated. Thank you.
我会尝试使用反向代理(例如 nginx)将您的应用程序公开到端口 80。然后将主机文件更改为您想要的任何内容。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.