【微信公众号开发】使用web.py框架进行python服务器搭建(1)

开启端口号

python3之后进行了改版(SimpleHTTPServer改成了http.server )(csdn是真的拉。。。日常吐槽)

sudo su - root 切换到root账户(服务器命令)(目前这个阶段不需要服务器)

libxml2改名为lxml

看到csdn的博客 安装错包了 导致一下午没有进展 一直debug。。。

如果版本不对的话 会提示你   generator raised StopIteration  错误。

安装官方安装的0.61的web.py版本

(安装时pip install 卸载时pip uninstall)

实验代码如下:

# -*- coding: utf-8 -*-
# filename: main.py
import web

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        return "Hello, world!"

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

  

然后在anaconda的命令窗口启动

 (开启端口号6295)

 (连接成功)

在命令窗口按ctrl+c就可以关闭连接了

分享一下腾讯公众号开发文档:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Getting_Started_Guide.html

原文地址:https://www.cnblogs.com/cckong/p/14274064.html