Jeese's Blog

  • 首页

  • 标签

  • 分类

  • 归档

  • 搜索

centos7下通过nginx+gunicorn部署django应用笔记

发表于 2019-03-31 | 更新于 2019-04-03 | 分类于 Django

centos7下通过nginx+gunicorn部署django应用笔记1.安装基础环境启动gunicorn新建虚拟环境imooc并切换到imooc pip install django==2.0 gunicorn django-admin startproject imooc cd imooc 命令行启动 gunicorn imooc.wsgi:application -w 2 -b 127. ...

阅读全文 »

django ORM应用笔记

发表于 2019-03-31 | 更新于 2019-04-03 | 分类于 Django

django ORM应用笔记1.常用字段类型和参数 数值型,右边为MySQL对应类型: AutoField int(11) Django默认提供,自增主键(也就是id) BooleanField tinyint(1) 布尔型 IntegerField int(11) 整数类型 PositiveIntegerField int(11) 正整数类型 字符型,右边为MySQL对应类型: CharFie ...

阅读全文 »

使用socket和线程池爬取数据

发表于 2019-03-28 | 分类于 Python

使用socket和线程池爬取数据# 使用socket和线程池爬取数据import socketfrom urllib.parse import urlparsedef get_url(url): #通过socket请求html url = urlparse(url) host = url.netloc# 提取主域名 path = url.path if path == ...

阅读全文 »

使用socket和asynico库爬取数据

发表于 2019-03-28 | 分类于 Python

### 使用socket和asynico库爬取数据# 使用socket和asynico库爬取数据#asyncio 没有提供http协议的接口 aiohttpimport asyncioimport socketfrom urllib.parse import urlparseasync def get_url(url): #通过socket请求html url = urlparse(u ...

阅读全文 »

python上下文管理类型

发表于 2019-03-28 | 分类于 Python

Python上下文管理类型# 上下文管理协议(常用于文件自动关闭、线程锁自动释放、数据库自动关闭连接、socket连接)# 最简单的实现class Sample(object): def __enter__(self): print("enter") return self def __exit__(self, exc_type, exc_val, exc_ ...

阅读全文 »

socket通信实现

发表于 2019-03-28 | 分类于 Python

socket通信实现使用多线程搞定多客户端连接# 使用多线程搞定多客户端连接# socket_client.pyimport socketclient = socket.socket(socket.AF_INET,socket.SOCK_STREAM)client.connect(("127.0.0.1",8888))while True: str1 = input() client. ...

阅读全文 »

Celery入门

发表于 2019-03-28 | 分类于 Python

Celery入门Celery基础Celery是一个专注于实时处理和任务调度的分布式任务队列。Celery特性:方便查看定时任务的执行情况(包含执行结果,执行状态,执行时间等)、任务支持后台管理(安装flower组件)、可选多进程Eventlet和Gevent三种模式执行任务、支持多种消息代理和后端存储 Celery包含的组件: Producer:任务生产者,可用task装饰器或其他方法将函数转化 ...

阅读全文 »

多线程与队列的运用

发表于 2019-03-28 | 分类于 Python

多线程与队列的运用(多进程,进程池,协程池)多线程和队列、多进程和队列# 多线程from queue import Queuefrom threading import Threadimport timequeue = Queue()def put_data(): for i in range(100): print("添加数据: {}".format(i) ...

阅读全文 »

django集成celery添加异步任务

发表于 2019-03-27 | 更新于 2019-04-03 | 分类于 Django

django集成celery添加异步任务django集成celery一.安装pip install celery[redis](windows不适用,4.1.0版本定时任务有bug) pip install redis==2.10.6 msgpack celery==3.1.20(windows采用方案) pip install django-celery-3.2.2 二.应用1.添加celery ...

阅读全文 »

django性能分析工具

发表于 2019-03-27 | 更新于 2019-04-03 | 分类于 Django

django-debug-toolbardjango-debug-toolbar是非常好用的django性能分析工具安装:pip install django-debug-toolbar# settings.py增加如下内容INSTALLED_APPS.append('debug_toolbar',)MIDDLEWARE.append('debug_toolbar.middleware.Debug ...

阅读全文 »
12…4

Jeese zhao

32 日志
3 分类
5 标签
GitHub
© 2018 – 2019 Jeese zhao
本站访客数:
由 Hexo 强力驱动 v3.8.0
|
主题 – NexT.Pisces v6.7.0
|