已有183人关注
代码在界面上打不开
发表在Python图书答疑 2019-02-23 悬赏:4 学分 《零基础学Python》第15章 Web编程
是否精华
版块置顶:

from wsgiref.simple_server import make_server

def app(environ,start_response):
    start_response('200 ok',[('Content-Type','text/htm;charset=utf-8'),( 'Date','Sat, 23 Feb 2019 09:19:04 GMT')])
##    print('*'*10)
##    print(environ['PATH_INFO'])
##    print('*'*10)
    file_name=environ['PATH_INFO'][1:] or'index.html'
    HTML_ROOT_DRT= './Viems/'
    try:
        file = open(HTML_ROOT_DRT+file_name,'rb')
    except:
        response ='File is not found'
    else:
        file_data=file.read()
        file.close()
        response =file_data.decode('utf-8')
    return [response.encode('utf-8')]

if __name__ =="__main__":
    ser =make_server('',8000,app)
    ser.serve_forever()
   


分享到:
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照