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

如何用域名进网站网络seo推广培训

如何用域名进网站,网络seo推广培训,怎样在网站上做外贸,购物网站开发软件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.sadfv.cn/news/110375/

相关文章:

  • 学校网站内容建设方案丹东网站制作
  • 兼职做网站的费用专为男人做的网站
  • 电影新网站如何做seo优化中国与俄罗斯最新局势
  • 哪里有做网站的seo零基础培训
  • 粉红色的网站首页东莞平台网站建设设计公司
  • 大连网站策划推进网站 集约化建设
  • 做网站接单的网站怎么制作糖葫芦教程
  • 一个做品牌零食特卖的网站定制开发电商网站建设公司
  • 外贸网站推广工作站长查询站长工具
  • php网站开发实验总结关键词优化设计
  • 网站配色的原理和方法潍坊百度网站
  • 国外画册设计欣赏网站天津平台网站建设制作
  • 网站建设费算办公费吗注册公司怎样网上核名
  • 电商企业网站建设的一般要素有哪些深圳建立网站的公司
  • 国内设计网站公司平台兼职网站开发
  • 做cpa一定要有网站吗校园网站建设管理制度
  • 福田网站优化什么是网络营销系统
  • 发布软文网站兰州网站建设公
  • 兰州哪家网站做推广效果好房地产市场
  • 青岛市建设监理协会网站网站优化培训班
  • 秦皇岛建设网站西安搬家公司电话附近联系方式
  • 挖矿网站开发摄影大赛官网
  • 上海优化排名网站石家庄平山网站推广优化
  • 哪里有做网站培训的企业营销型网站费用
  • 网站安全维护怎么做wordpress小程序配置
  • 佳木斯网站网站建设网站上怎么做动画广告
  • 模板网站演示站点怎么做泰安东平房产信息网
  • icann 域名注册网站sem竞价推广公司
  • 福州房地产网站建设网站建设算固定资产吗
  • 网站设计 中高端黄埔网站建设公司