Python的Bottle框架基本知识总结

2019-10-17 20:23:32丽君

 

# /var/www/yourapp/app.wsgi
import bottle
# ... add or import your bottle app code here ...
# import myapp
application = bottle.default_app()
# Do NOT use bottle.run() with mod_wsgi

Apache配置可能如下:
 

<VirtualHost *>
  ServerName example.com

  WSGIDaemonProcess yourapp user=www-data group=www-data processes=1 threads=5
  WSGIScriptAlias / /var/www/yourapp/app.wsgi

  <Directory /var/www/yourapp>
    WSGIProcessGroup yourapp
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
  </Directory>
</VirtualHost>

Google AppEngine

import bottle
from google.appengine.ext.webapp import util 
# ... add or import your bottle app code here ...
# import myapp
# Do NOT use bottle.run() with AppEngine
util.run_wsgi_app(bottle.default_app())

CGI模式

运行缓缓,但可以正常工作.

import bottle
# ... add or import your bottle app code here ...
bottle.run(server=bottle.CGIServer)