微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析

小編給大家分享一下微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

從事成都服務(wù)器托管,服務(wù)器租用,云主機(jī),虛擬空間,國(guó)際域名空間,CDN,網(wǎng)絡(luò)代維等服務(wù)。

[root@mail ~]# uname -aLinux mail.vtata.cn 2.6.18-128.el5xen #1 SMP Wed Jan 21 11:12:42 EST 2009 x86_64 x86_64 x86_64 GNU/Linux[root@mail ~]# cat /etc/redhat-release CentOS release 5.3 (Final)
Python Version:
[root@mail ~]# pythonPython 2.7.5 (default, Jun 14 2013, 18:21:34) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2Type "help", "copyright", "credits" or "license" for more information
uwsgi Version:
uWSGI 1.4.9
web.py Version:
web.py-0.37

首先是安裝所需程序,因?yàn)镃entos自帶的Python是2.4,如果不更新至2.7會(huì)發(fā)生模塊導(dǎo)入錯(cuò)誤等問(wèn)題,

tar xvf Python-2.7.5.tgz
cd Python-2.7.5
./configure && make all && make install && make distclean
mv /usr/bin/python /usr/bin/python.bak
ln -sv /usr/local/bin/python2.7 /usr/bin/python
sed -i s@/usr/bin/python@/usr/bin/python2.4@ /usr/bin/yum
tar zxvf uwsgi-1.4.9.tar.gz
cd uwsgi-1.4.9
python uwsgiconfig.py --build
python setup.py install
tar zxvf web.py-0.37.tar.gz
cd web.py-0.37
python setup.py install

本次是通過(guò)uwsgi與nginx結(jié)合進(jìn)行使用,關(guān)于uwsgi與nginx整合請(qǐng)參加前一篇文章。

編寫(xiě)驗(yàn)證代碼如下:

文件名:webinput.py

import web
import hashlib
urls = (
    '/','index'
)
class index:
    def GET(self):
        token='shiji'
        sign = web.input()
        tmplist = [token,sign.timestamp,sign.nonce]
        tmplist.sort()
        tmpstr = "%s%s%s"%tuple(tmplist)
        tmpstr = hashlib.sha1(tmpstr).hexdigest()
        if tmpstr == sign.signature:
            return sign.echostr
        else:
            return None
app = web.application(urls,globals())
application = app.wsgifunc()

啟動(dòng)nginx后啟動(dòng)uwsgi,啟動(dòng)過(guò)程如下:

[root@mail html]# uwsgi -s 127.0.0.1:9000 -w webinput
*** Starting uWSGI 1.4.9 (64bit) on [Mon Jun 17 17:19:16 2013] ***
compiled with version: 4.1.2 20080704 (Red Hat 4.1.2-44) on 17 June 2013 17:15:20
os: Linux-2.6.18-128.el5xen #1 SMP Wed Jan 21 11:12:42 EST 2009
nodename: mail.vtata.cn
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /usr/local/nginx/html
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 61234
your memory page size is 4096 bytes
detected max file descriptor number: 52100
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:9000 fd 3
Python version: 2.7.5 (default, Jun 14 2013, 18:21:34)  [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xfe30520
your server socket listen backlog is limited to 100 connections
mapped 72424 bytes (70 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xfe30520 pid: 10775 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 10775, cores: 1)
13712480011371460796shiji
[pid: 10775|app: 0|req: 1/1] 101.226.33.171 () {34 vars in 616 bytes} [Mon Jun 17 17:19:43 2013] GET /?signature=915c123b81282828ae1eecdc202336d07dfc15d8&echostr=5889465363321509055&timestamp=1371460796&nonce=1371248001 => generated 4 bytes in 2 msecs (HTTP/1.0 200) 0 headers in 19 bytes (2 switches on core 0)

打開(kāi)微信公眾平臺(tái)界面,在高級(jí)功能里面進(jìn)行設(shè)置如圖:

微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析

微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析

看完了這篇文章,相信你對(duì)“微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

本文名稱:微信公眾賬號(hào)開(kāi)發(fā)者認(rèn)證之uwsgi結(jié)合web.py的示例分析
標(biāo)題鏈接:http://muchs.cn/article28/pihgjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、網(wǎng)站排名、全網(wǎng)營(yíng)銷推廣域名注冊(cè)、網(wǎng)站設(shè)計(jì)、App開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開(kāi)發(fā)公司