Zachary1994
2015-11-07 07:36OpenWrt上运行python3的bottle模块运行出错
5python3的相关模块都已安装,相关python代码如下:
# -*- coding: utf-8 -*-
from bottle import Bottle, run
app=Bottle()
@app.route('/hello')
def hello():
return '<strong>Hello world!</strong>'
run(app,host='localhost',port=81)
以上代码运行正确,但是我想在局域网下访问,把host改为局域网ip192.168.1.1后运行结果如下:
Bottle v0.12.8 server starting up (using WSGIRefServer())...
Listening on http://192.168.1.1:81/
Hit Ctrl-C to quit.
Traceback (most recent call last):
File "bottle_test.py", line 10, in <module>
run(app,host='192.168.1.1',port=81)
File "/usr/lib/python3.4/bottle.py", line 3117, in run
server.run(app)
File "/usr/lib/python3.4/bottle.py", line 2771, in run
srv = make_server(self.host, self.port, app, server_cls, handler_cls)
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 153, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.4/socketserver.py", line 430, in __init__
self.server_bind()
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.4/http/server.py", line 135, in server_bind
self.server_name = socket.getfqdn(host)
File "/usr/lib/python3.4/socket.py", line 463, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte
我怀疑是编码问题,但是确认python中sys编码为utf-8,该py文件编码也是utf-8。求助!
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 本人小白,请大神支持:openwrt usb 打印机报错
- linux
- 1个回答
- 为什么在OpenWRT上运行Golang的time.Now()总是获得UTC时间?
- openwrt
- 2个回答
- 使用.htaccess和php进行URL重定向问题
- apache
- redirect
- php
- 1个回答
- curl交叉编译成动态库,运行是失败报错
- c++
- 1个回答
- CSS背景未显示
- html
- php
- 2个回答
换一换