当前位置: 首页 > news >正文

西安站在哪里做推广效果好

西安站,在哪里做推广效果好,排名优化公司哪里有,wordpress 导航加图标bottle是一个轻量级的pythonweb框架#xff0c; 可以适配各种web服务器#xff0c;包括python自带的wsgiref(默认)#xff0c;gevent#xff0c; cherrypy#xff0c;gunicorn等等。bottle是单文件形式发布#xff0c;源码在这里可以下载#xff0c;代码量不多#xff…bottle是一个轻量级的pythonweb框架 可以适配各种web服务器包括python自带的wsgiref(默认)gevent cherrypygunicorn等等。bottle是单文件形式发布源码在这里可以下载代码量不多可以用来学习web框架。这里也有官方文档的中文翻译。     首先我们来运行一下bottle的hello worldfrom bottle importrunif __name__ __main__:defapplication(environ, start_response):start_response(200 OK, [(Content-Type, text/html)])return [Hello world!]run(hostlocalhost, port8080, appapplication)上面的代码看起来也非常符合wsgi的接口规范。启动改代码可以看到输出         Bottle v0.13-dev server starting up (usingWSGIRefServer())…         Listening on http://localhost:8080/         Hit Ctrl-C to quit.      输出中加粗部分表明使用的web服务器是python自带的wsgiref。也可以使用其他web server比如gevent前提是需要安装gevent修改后的代码如下from bottle importrunimportgevent.monkeygevent.monkey.patch_all()if __name__ __main__:defapplication(environ, start_response):start_response(200 OK, [(Content-Type, text/html)])return [Hello world!]run(hostlocalhost, port8080, appapplication, server gevent)通过server关键字指定web服务器为‘gevent’输出的第一行变成了Bottle v0.13-dev server starting up (usingGeventServer())…   不管bottle用什么web服务器启动在浏览器输入127.0.0.1:8080都可以看到       下面介绍bottle中部分类和接口bottle.Bottle     代表一个独立的wsgi应用由一下部分组成routes, callbacks, plugins, resources and configuration。     __call__: Bottle定义了__call__函数, 使得Bottle的实例能成为一个callable。在前文提到web框架(或Application)需要提供一个callbale对象给web服务器bottle提供的就是Bottle实例def __call__(self, environ, start_response):Each instance of :class:Bottle is a WSGI application.return self.wsgi(environ, start_response)下面是Bottle.wsgi函数的核心代码主要调用两个比较重要的函数_handle, _castdefwsgi(self, environ, start_response):The bottle WSGI-interface.try:outself._cast(self._handle(environ))#rfc2616 section 4.3if response._status_code in (100, 101, 204, 304)\or environ[REQUEST_METHOD] HEAD:if hasattr(out, close): out.close()out[]start_response(response._status_line, response.headerlist)return out_handle处理请求最终调用到application 简化后的代码如下1   def_handle(self, environ):2 self.trigger_hook(before_request)3 route, args self.router.match(environ)4 out route.call(**args)5 self.trigger_hook(after_request)6 return out_cast:         标准的wsgi接口对Application的返回值要求严格必须迭代返回字符串。bottle做了一些扩展可以允许App返回更加丰富的类型比如dictFile等。 _cast函数对_handle函数返回值进行处理使之符合wsgi规范bottle.Route     封装了路由规则与对应的回调bottle.RouterA Router is an ordered collection of route-target pairs. It is used to  efficiently match WSGI requests against a number of routes and return the first target that satisfies the request.ServerAdapter     所有bottle适配的web服务器的基类子类只要实现run方法就可以了bottle里面有大量的Web服务器的适配。下表来自官网介绍了bottle支持的各种web服务器以及各自的特性。NameHomepageDescriptioncgiRun as CGI scriptflupRun as FastCGI processgaeHelper for Google App Engine deploymentswsgirefSingle-threaded default servercherrypyMulti-threaded and very stablepasteMulti-threaded, stable, tried and testedrocketMulti-threadedwaitressMulti-threaded, poweres PyramidgunicornPre-forked, partly written in CeventletAsynchronous framework with WSGI support.geventAsynchronous (greenlets)dieselAsynchronous (greenlets)fapws3Asynchronous (network side only), written in CtornadoAsynchronous, powers some parts of FacebooktwistedAsynchronous, well tested but… twistedmeinheldAsynchronous, partly written in CbjoernAsynchronous, very fast and written in CautoAutomatically selects an available server adapter可以看到bottle适配的web服务器很丰富。工作模式也很全面有多线程的(如paste)、有多进程模式的(如gunicorn)、也有基于协程的(如gevent)。具体选择哪种web服务器取决于应用的特性比如是CPU bound还是IO boundbottle.run     启动wsgi服务器。几个比较重要的参数     app wsgi application即可以是bottle.Bottle 也开始是任何满足wsgi 接口的函数     server wsgi http server字符串     hostport 监听端口          核心逻辑     ServerAdapter.run(app)。   最后bottle源码中有一些使用descriptor的例子实现很巧妙值得一读前文也有介绍。   referenceshttp://www.bottlepy.org/docs/dev/https://raw.githubusercontent.com/bottlepy/bottle/master/bottle.pyhttp://blog.csdn.net/huithe/article/details/8087645http://simple-is-better.com/news/59http://www.bottlepy.org/docs/dev/deployment.html#server-optionshttp://blog.rutwick.com/use-bottle-python-framework-with-google-app-engine
http://www.zqtcl.cn/news/203683/

相关文章:

  • 东莞网站建设包装制品flash网站制作
  • 办网站怎么赚钱做二手电脑的网站
  • 大型电子商务网站建设成本旅游网站前台怎么做
  • 深圳网站建设..网站点击图片放大
  • 上海企业扶持政策洛阳400电话洛阳网站seo
  • 保亭县住房城市建设局网站app免费制作平台下载
  • 抚州市建设局网站在网站做商城平台需要哪些资质
  • 潍坊专业网站建设多少钱素马设计官网
  • 深圳网站建设 套餐近期新闻事件
  • 网站开发外包维护合同淘宝客源码程序 爱淘宝风格+程序自动采集商品 淘宝客网站模板
  • 烟台企业网站开发军事新闻最新24小时
  • wordpress网站更换域名网站空间建站
  • 十堰网站建设公司电话网页设计与制作教程江西高校出版社
  • 英文网站seo常州建设局考试网站
  • wordpress 多网站哈尔滨 建网站
  • 免费网站源代码怎么制作网站教程
  • Thinkphp开发wordpress网站怎么优化seo
  • tp框架做视频网站站长统计芭乐鸭脖小猪
  • asp网站发布ftp国内f型网页布局的网站
  • 无限空间 网站四川省建设厅网站填报获奖
  • 广东佛山最新通知北京seo怎么优化
  • 浙江省通信管理局 网站备案 管理部门科技公司经营范围包括哪些
  • 网站域名备案转接入手续深圳外贸公司qc招聘
  • 湖北网站建设服务公司可以做产品推广的网站
  • 做经营性的网站备案条件wordpress删除菜单
  • js商城网站个安装wordpress
  • 想给学校社团做网站企业服务平台是做什么的
  • 网站推广渠道的类型wordpress看不到表格
  • 网站建设与推广实训报告册附近广告设计与制作门店电话
  • wordpress汉语公益网站开发使用api对seo