微信 python搭建服务器
1. 搭建服务
以web.py网络框,python,腾讯云服务器为例介绍。
1)安装/更新需要用到的软件
安装python2.7版本以上
安装web.py
pip install web.py
sudo apt-get install python-lxml
sudo apt-get install libxml2 sudo apt-get install libxml2-dev
安装libxml2, libxslt, lxml python
2)编辑代码,如果不懂python 语法,请到python官方文档查询说明。vim main.py
参考文献
服务器代码
1. vim main.py # -*- coding: utf-8 -*-
# filename: main.py
import web
from handle import Handle urls = (
'/wx', 'Handle',
) if __name__ == '__main__':
app = web.application(urls, globals())
app.run()
. vim handle.py # -*- coding: utf- -*-
# filename: handle.py import hashlib
import web class Handle(object):
def GET(self):
try:
data = web.input()
if len(data) == :
return "hello, this is handle view"
signature = data.signature
timestamp = data.timestamp
nonce = data.nonce
echostr = data.echostr
token = "yuhailong" #请按照公众平台官网\基本配置中信息填写 list = [token, timestamp, nonce]
list.sort()
sha1 = hashlib.sha1()
map(sha1.update, list)
hashcode = sha1.hexdigest()
print "handle/GET func: hashcode, signature: ", hashcode, signature
if hashcode == signature:
return echostr
else:
return ""
except Exception, Argument:
return Argument
4) 重新启动成功后(python main.py 80),点击提交按钮。若提示”token验证失败”, 请认真检查代码或网络链接等。若token验证成功,会自动返回基本配置的主页面,点击启动按钮
参考文献:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1472017492_58YV5
微信 python搭建服务器的更多相关文章
- python搭建服务器时nginx的有关问题
最近在学习Python服务器搭建的内容,网上大多是Windows环境下的,由于我使用的是Mac,为了不想装双系统折腾,就只好一步步采坑了.比较基础的我一步步记录下来, 1.安装nginx: brew ...
- Django + Apache + 树莓派 搭建内网微信公众号服务器
其实早在微信开放公众号开发平台时就想弄一个自己的公众号服务器,奈何对web服务器搭建和开发一窍不通,只是注册了一下开发者帐号,并没有采取行动,万恶的拖延症. 前一年,开始接触python,打开了神奇世 ...
- linux+apache+mod_python+wechat_sdk搭建微信公共账号服务器
linux+apache+mod_python+wechat_sdk搭建微信公共账号服务器 转载请注明本文原作者:FignerLiu PRE 最近尝试了下使用python搭建微信公共账号服务器,实现了 ...
- Python搭建Web服务器,与Ajax交互,接收处理Get和Post请求的简易结构
用python搭建web服务器,与ajax交互,接收处理Get和Post请求:简单实用,没有用框架,适用于简单需求,更多功能可进行扩展. python有自带模块BaseHTTPServer.CGIHT ...
- Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器 闲着无聊的时候部署了一个Django项目玩,用vm虚拟机部署的. 准备工作 我使用的系统是Ubuntu16 ...
- python搭建简易服务器实例参考
有关python搭建简易服务器的方法. 需求分析: 省油宝用户数 已经破了6000,原有的静态报表 已经变得臃肿不堪, 每次打开都要缓上半天,甚至浏览器直接挂掉 采用python搭建一个最最简易的 w ...
- python搭建本地服务器
python搭建本地服务器 python3以上版本 'python3 -m http.server 8000' 默认是8000端口,可以指定端口,打开浏览器输入http://127.0.0.1:800 ...
- 树莓派搭建python环境服务器
树莓派搭建python环境服务器 服务器结构大致为:django+uwsgi+nginx+python+sqlite 配置python环境 系统本身自带了python2.7和python3.5.在这里 ...
- python搭建友盟以及个推推送web服务器
一.友盟客户端demo: 由于SDK原因,新版Android Studio的Android API 28 Platform无法同步新建项目, 所以我最终选择下载android-studio-bundl ...
随机推荐
- frontend-tools
收集整理好用的前端开发利器(Collect good front-end development tools ) 1.w3cplus前端工具 2.jsfiddle在线JS代码调试工具 3.w3cfun ...
- android客户端登录&注册的实现
MainActivity多线程的实现: package com.example.loginconnect; import java.lang.ref.WeakReference; import jav ...
- Android OTA在线升级二(升级包编译原理分析) 【转】
本文转载自:http://blog.csdn.net/huryjiang/article/details/7590015 1 升级包的制作 基本命令: Ø makeMtk [project[flav ...
- HTTPSQS(HTTP Simple Queue Service)消息队列
HTTPSQS(HTTP Simple Queue Service)是一款基于 HTTP GET/POST 协议的轻量级开源简单消息队列服务,使用 Tokyo Cabinet 的 B+Tree Key ...
- C程序员必须知道的内存知识【英】
C程序员必须知道的内存知识[英] 时间 2015-03-08 14:16:11 极客头条原文 http://marek.vavrusa.com/c/memory/2015/02/20/memory ...
- STL头文件有哪些及简单介绍
#include <iostream>标准输入输出cin cout等 #include <algorithm> 算法库 如sort find等 #include <vec ...
- Sqoop-1.4.4工具import和export使用详解
转自:http://blog.csdn.net/wodatoucai/article/details/46343291 Sqoop可以在HDFS/Hive和关系型数据库之间进行数据的导入导出,其中主要 ...
- adobe flash player 下载地址
1. https://www.adobe.com/cn/products/flashplayer/distribution3.html
- webserver的编写中出现的问题
在webserver编写过程中,出现过问题.就是标签<input>编写过程中少了name属性,导致程序无法读到<form>提交的数据.
- Selenium-几种元素定位方式
#识别元素并操作#一般有如下几种方法,其中id最为常用.这里需要注意识别元素一定要用唯一id 1.find_element_by_id("value") #! /usr/bin/e ...