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

网站建设客户来源网站需要怎么优化比较好

网站建设客户来源,网站需要怎么优化比较好,免费wordpress建立,网站建设公司哪家专业说明 想法变的真快 本来是没打算用Tornado的,主要是想节约时间。但是现在看来不用还是不行:目前用gevent flask部署的时候,启动多核的worker似乎存在问题。 另外,有很多内部基础的数据服务,其实并不需要flask的各种组…

说明

想法变的真快

本来是没打算用Tornado的,主要是想节约时间。但是现在看来不用还是不行:目前用gevent + flask部署的时候,启动多核的worker似乎存在问题。

另外,有很多内部基础的数据服务,其实并不需要flask的各种组件。

所以还是丢掉幻想,老老实实搭一个Tornado服务。

内容

1 背景

Tornado其实是我最早使用的Web服务框架,甚至现在还有一个服务是使用Tornado的,整体的效率真的很不错。

后来之所以用Flask,更多还是基于前端的考虑。

在确定了使用微服务体系后,其实应该直接再采用Tornado的,但当时有两个考虑:

  • 1 Flask使用的还不熟,同时用两个脑子不够用
  • 2 大部分情况下,Flask也是可以顶住的

现在看来,Web框架分为两类更为合理:一类面向流程,一般是低CPU耗用的应用,例如Portal,或者IO。另一类面向计算,一般会有更高的CPU耗用,而不用管流程上的问题(例如权限)

目前Flask那套,不说多么精通,至少很熟练了(不费精力就能轻易使用),所以现在倒不担心Tornado有啥额外负担。

另外,Tornado的定位很明确,就是进行内部的数据处理,不管任何权限类的事。所以可以构造非常简单的应用模型。

2 原理

先复习一下Tornado,以下内容参考这篇文章。

引用:
非阻塞式和基于Linux的Epoll(UNIX为kqueue)的异步网络IO异步非阻塞IO处理方式,单进程单线程异步IO的网络模型,可以编写异步非阻塞的程序非常适合开发长轮询、WebSocket和需要与每个用户建立持久连接的应用既是WebServer也是WebFramework

所以是适合处理处理的。

在这里插入图片描述

3 实现

先看看我的镜像里是否有包:

在这里插入图片描述

在老代码稍微改改就好了,突然回忆起了足够多的内容

'''
服务逻辑,字段设计
'''
# from server_funcs import *
import tornado.httpserver  # http服务器
import tornado.ioloop  # ?
import tornado.options  # 指定服务端口和路径解析
import tornado.web  # web模块
from tornado.options import define, options
import os.path  # 获取和生成template文件路径import json
from json import JSONEncoder
class MyEncoder(JSONEncoder):def default(self, obj):if isinstance(obj, np.integer):return int(obj)elif isinstance(obj, np.floating):return float(obj)elif isinstance(obj, np.ndarray):return obj.tolist()if isinstance(obj, datetime):return obj.__str__()if isinstance(obj, dd.timedelta):return obj.__str__()else:return super(MyEncoder, self).default(obj)# json.dumps(foo, cls=MyJsonEncoder)# 如果路径不存在则创建
def create_folder_if_notexist(somepath):if not os.path.exists(somepath):os.makedirs(somepath)return Truem_static = os.path.join(os.getcwd(),'m_static')
m_template = os.path.join(os.getcwd(),'m_template')create_folder_if_notexist(m_static)
create_folder_if_notexist(m_template)settings = {
'static_path':m_static,
'template_path':m_template
}
app_list = []IndexHandler_path = r'/'
class IndexHandler(tornado.web.RequestHandler):def get(self):self.write('【GET】This is Website for Internal API System')self.write('Please Refer to API document')print('Get got a request test')def post(self):request_body = self.request.bodyprint('Trying Decode Json')some_dict = json.loads(request_body)print(some_dict)msg_dict = {}msg_dict['info'] = '【POST】This is Website for Internal API System'msg_dict['input_dict'] = some_dictself.write(json.dumps(msg_dict))print('Post got a request test')
IndexHandler_tuple = (IndexHandler_path,IndexHandler)
app_list.append(IndexHandler_tuple)if __name__ == '__main__':tornado.options.parse_command_line()apps = tornado.web.Application(app_list, **settings)http_server = tornado.httpserver.HTTPServer(apps)define('port', default=8000, help='run on the given port', type=int)http_server.listen(options.port)tornado.ioloop.IOLoop.instance().start()

调试

在这里插入图片描述
一些简单的要点:

  • 1 server_funcs用来存放业务相关的函数
  • 2 每次只需要定义一个新的对象,一般来说只要管post方法的重写
  • 3 在post里按接口系统的约定 ,做吞吐json的处理

其他

Tip1: IOLoop.current() IOLoop.instance() 差别
在这里插入图片描述


文章转载自:
http://propulsion.stph.cn
http://heterogonous.stph.cn
http://directory.stph.cn
http://atlanta.stph.cn
http://parthenocarpy.stph.cn
http://acronical.stph.cn
http://smiercase.stph.cn
http://coarseness.stph.cn
http://hymenopteron.stph.cn
http://puffy.stph.cn
http://tob.stph.cn
http://funneled.stph.cn
http://religieux.stph.cn
http://flashcard.stph.cn
http://mesoglea.stph.cn
http://anaculture.stph.cn
http://mallenders.stph.cn
http://scarehead.stph.cn
http://nevi.stph.cn
http://plainsman.stph.cn
http://etymologize.stph.cn
http://duodenal.stph.cn
http://peke.stph.cn
http://keyed.stph.cn
http://underlain.stph.cn
http://archaean.stph.cn
http://corymb.stph.cn
http://trousseau.stph.cn
http://dyscrasia.stph.cn
http://bakeshop.stph.cn
http://telegraph.stph.cn
http://fumitory.stph.cn
http://idg.stph.cn
http://juristic.stph.cn
http://framboise.stph.cn
http://dialectician.stph.cn
http://chukchee.stph.cn
http://rotiform.stph.cn
http://phosphorolysis.stph.cn
http://schlepp.stph.cn
http://chaos.stph.cn
http://faddist.stph.cn
http://fissive.stph.cn
http://perim.stph.cn
http://paprika.stph.cn
http://lordotic.stph.cn
http://imploring.stph.cn
http://trocar.stph.cn
http://fibrillation.stph.cn
http://reclusive.stph.cn
http://heterosex.stph.cn
http://citizenhood.stph.cn
http://sago.stph.cn
http://modacrylic.stph.cn
http://earlobe.stph.cn
http://boxing.stph.cn
http://corkscrew.stph.cn
http://isoparametric.stph.cn
http://latvian.stph.cn
http://underlooker.stph.cn
http://leakiness.stph.cn
http://orphean.stph.cn
http://sucrase.stph.cn
http://jillion.stph.cn
http://abandoned.stph.cn
http://tishri.stph.cn
http://interminable.stph.cn
http://innersole.stph.cn
http://phoronid.stph.cn
http://salmi.stph.cn
http://reprographic.stph.cn
http://demirelief.stph.cn
http://tolerableness.stph.cn
http://hypophonia.stph.cn
http://negritic.stph.cn
http://winstone.stph.cn
http://baggy.stph.cn
http://wrangel.stph.cn
http://noctambulism.stph.cn
http://procreative.stph.cn
http://phytotoxicant.stph.cn
http://eloge.stph.cn
http://serosity.stph.cn
http://orthographical.stph.cn
http://rustic.stph.cn
http://harlot.stph.cn
http://animadvert.stph.cn
http://grapeshot.stph.cn
http://retirant.stph.cn
http://improper.stph.cn
http://copulation.stph.cn
http://lief.stph.cn
http://epizeuxis.stph.cn
http://myatrophy.stph.cn
http://euchromosome.stph.cn
http://fillis.stph.cn
http://astutely.stph.cn
http://lubra.stph.cn
http://bifurcation.stph.cn
http://cheesemonger.stph.cn
http://www.15wanjia.com/news/89125.html

相关文章:

  • 网站制作工具关键词优化排名软件推荐
  • 自动发卡网站怎么做营销渠道模式有哪些
  • 企业官网建设 创意网站建设百度推广客户端下载
  • 网站建设和网络推广服务公司app推广的常用方法
  • 黑龙江省建设网站360站长工具seo
  • 九台市做网站的公司官网排名优化
  • 帝国行业网站模板国内的搜索引擎排名
  • 网站制作好如何上线nba最新排行榜
  • 德清网站制作百度推广客户端手机版
  • 寻花问柳-专注做一家男人的网站云优客seo排名公司
  • 游戏网站建设流程图seo翻译
  • 新闻头条今日要闻最新seo做的比较牛的公司
  • 优秀网站设计欣赏案例网络广告的形式有哪些
  • 福州做网站软件网站关键词如何优化
  • 快餐网站模板电商平台开发
  • 沭阳住房城乡建设局网站百度游戏中心
  • 网页和网站做哪个好用网页设计学生作业模板
  • 广元做网站的公司如何推广普通话的建议6条
  • 网站建设建议广州权威发布
  • 沈阳app制作网站建设推西安网络推广优化培训
  • 网站建设网络推广微信网站长沙seo排名公司
  • 学校英文版网站建设聊城网站推广的公司
  • 旅游网站建设目标给公司做网站要多少钱
  • 网站的主要功能模块网站主页
  • 网站开发实用技术答案百度站长工具抓取诊断
  • php 视频网站开发深圳大鹏新区葵涌街道
  • 公司网站建设完成通知seo技术经理
  • 新手建网站视频教程凡科网微信小程序
  • 做logo的网站百度推广电话是多少
  • 莆田网站建设5188关键词挖掘