Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python Web¿ª·¢ÓëApache2+mod_wsgi²¿Êð

×î½üÔÚ¿´Python Web·½ÃæµÄ¿ª·¢£¬³õ²½½Ó´¥ÁËDjangoºÍweb.py(×¢:ºÍweb2pyÍêÈ«²»Ïà¹Ø)Á½¸ö¿ò¼Ü¡£
Èç¹û½áºÏApache²¿ÊðÐèҪһЩÑо¿£¬¿ÉÄܶÔCGIµÄ²»ÊìϤ°É¡£ËäÈ»mod_pythonÒ²¿ÉÒÔ£¬µ«Ëƺõ¸üÁ÷ÐÐmod_wsgi 
,ÎÒÊÇÔÚUbuntu°²×°µÄ,±¾À´ÏëÔ´Âë±àÒëµÄ£¬¿ÉÊÇmakeµÄʱºò×ÜÊDZ¨´í£¬×îºó$sudo apt-get install libapache2-mod-wsgi ,µ¹Ò²¼òµ¥¡£
×¢:Èç¹û²ÉÓñàÒëµÄ·½Ê½£¬ÐèҪԤװapxs2(apxs is the tool for building modules for Apache (apxs2 is for apache2),
$sudo apt-get install apache2-threaded-dev
×°ºÃ¾ÍÊÇÐÞ¸ÄÅäÖÃÎļþÁË,Ö÷ÒªÊÇÐÞ¸Ä/etc/apache2/sites-available/defaultÎļþ:
»ù±¾ÕÕ×ÅÏòµ¼
À´¾Í¿ÉÒÔ£¬ÒòΪÊÇÓ¢Îĵģ¬ÕâÀï¼òÒª½éÉÜÈçÏÂ:
ÔÚVirtualHostÄÚÌí¼Ó
   #²ÉÓÃÊØ»¤Ä£Ê½¶ø·ÇÄÚǶģʽ
   WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP}
   WSGIProcessGroup example.com
   ££´´½¨python½Å±¾Ö´ÐеıðÃû,ÍÆ¼ö³ÌÐò½Å±¾·ÅÔÚ¶ÀÁ¢µÄĿ¼¶ø·ÇDocumentRoot
    WSGIScriptAlias /mywebpy /usr/local/mywebpy/index.py
    <Directory /usr/local/mywebpy>
    Order allow,deny
    Allow from all
    </Directory>
web.pyʵÀý´úÂëÈçÏÂ:
#!/usr/bin/env python
import web
urls = (
'/(.*)', 'hello'
)
class hello:
def GET(self, name):
i = web.input(times=1)
if not name: name = 'world'
for c in xrange(int(i.times)): print'Hello,', name+'!'
application = web.application(urls, globals()).wsgifunc()

µ½ÕâÀï,»¹ÓÐÒ»¸öÎÊÌ⣬ÄǾÍÊÇ´úÂëÖеÄprintÓï¾ä²¢²»±»mod_wsgiÖ§³Ö£¬Äã¿ÉÄܻῴµ½internal errorÖ®ÀàµÄÐÅÏ¢£¬Í¨¹ý/var/log/apache2/error.og¿ÉÒÔ¿´µ½ÏêϸµÄÐÅÏ¢£¬ÄÇÊÇÒòΪ±ê×¼ÊäÈë/Êä³öµÄÓï¾äÔÚWSGIÖÐÊDz»ÔÊÐíµÄ£¬Ô­ÒòÈçÏ£º
Q: Why do I get the error 'IOError: sys.stdout access restricted by mod_wsgi'?
A: A portable WSGI application or application component should not output anything to standard output. This is because some WSGI hosting mechanisms use standard output to communicate with the web server. If a WSGI application outputs anything to standard outpu


Ïà¹ØÎĵµ£º

python hidden features

from http://stackoverflow.com/questions/101268/hidden-features-of-python
http://www.okpython.com/bbs/thread-3434-1-1.html
http://www.okpython.com/bbs/thread-3436-1-2.html
http://www.okpython.com/bbs/thread-3437-1-2.html
http://www.okpython.com/bbs/thread-3438-1-1.html
http://www.okpython.com/bb ......

python self __init__

self
ÀàµÄ·½·¨ÓëÆÕͨµÄº¯ÊýÖ»ÓÐÒ»¸öÌØ±ðµÄÇø±ð——ËüÃDZØÐëÓÐÒ»¸ö¶îÍâµÄµÚÒ»¸ö²ÎÊýÃû³Æ£¬µ«ÊÇ
ÔÚµ÷ÓÃÕâ¸ö·½·¨µÄʱºòÄ㲻ΪÕâ¸ö²ÎÊý¸³Öµ£¬Python»áÌṩÕâ¸öÖµ¡£Õâ¸öÌØ±ðµÄ±äÁ¿Ö¸¶ÔÏó±¾
Éí£¬°´ÕÕ¹ßÀýËüµÄÃû³ÆÊÇself¡£
ÕâÒ²Òâζ×ÅÈç¹ûÄãÓÐÒ»¸ö²»ÐèÒª²ÎÊýµÄ·½·¨£¬Ä㻹ÊǵøøÕâ¸ö·½·¨¶¨ÒåÒ»¸öself²ÎÊý¡£
__init_ ......

³£ÓõÄpythonÄ£¿é

from link http://www.tt010.net/cms/show_article/1057.html ·¢±íÆÀÂÛ Post by : BossAdmin @[2009-12-12 17:11:20] views:115 adodb£ºÎÒÃÇÁìµ¼ÍÆ¼öµÄÊý¾Ý¿âÁ¬½Ó×é¼þ bsddb3£ºBerkeleyDBµÄÁ¬½Ó×é¼þ Cheetah-1.0£ºÎұȽÏϲ»¶Õâ¸ö°æ±¾µÄcheetah cherrypy£ºÒ»¸öWEB framework ctypes£ºÓÃÀ´µ÷Óö¯Ì¬Á´½Ó¿â DBUtils£ºÊý ......

Python continue

1.º¯Êý
º¯Êýͨ¹ýdef¹Ø¼ü×Ö¶¨Òå¡£def¹Ø¼ü×Öºó¸úÒ»¸öº¯ÊýµÄ ±êʶ·û
Ãû³Æ£¬È»ºó¸úÒ»¶ÔÔ²À¨ºÅ¡£Ô²À¨ºÅÖ®ÖпÉÒÔ°üÀ¨Ò»Ð©±äÁ¿Ãû£¬¸ÃÐÐÒÔðºÅ½áβ¡£½ÓÏÂÀ´ÊÇÒ»¿éÓï¾ä£¬ËüÃÇÊǺ¯ÊýÌå¡£º¯ÊýÒ²ÓÐÐβκÍʵ²Î£¬ÓëC++Ψһ²»Ò»ÑùµÄÊÇÐββ»Ð´ÀàÐͶøÒÑ£¬Ö±½Óд±äÁ¿Ãû¡£
2.globalÓï¾ä
Èç¹ûÄãÏëҪΪһ¸ö¶¨ÒåÔÚº¯ÊýÍâµÄ±äÁ¿¸³Öµ£¬ÄÇÃ´Ä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ