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应用笔记
django ORM应用笔记1.常用字段类型和参数 数值型,右边为MySQL对应类型: AutoField int(11) Django默认提供,自增主键(也就是id) BooleanField tinyint(1) 布尔型 IntegerField int(11) 整数类型 PositiveIntegerField int(11) 正整数类型 字符型,右边为MySQL对应类型: CharFie ...
使用socket和线程池爬取数据
使用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库爬取数据
### 使用socket和asynico库爬取数据# 使用socket和asynico库爬取数据#asyncio 没有提供http协议的接口 aiohttpimport asyncioimport socketfrom urllib.parse import urlparseasync def get_url(url): #通过socket请求html url = urlparse(u ...
python上下文管理类型
Python上下文管理类型# 上下文管理协议(常用于文件自动关闭、线程锁自动释放、数据库自动关闭连接、socket连接)# 最简单的实现class Sample(object): def __enter__(self): print("enter") return self def __exit__(self, exc_type, exc_val, exc_ ...
socket通信实现
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. ...
django集成celery添加异步任务
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性能分析工具
django-debug-toolbardjango-debug-toolbar是非常好用的django性能分析工具安装:pip install django-debug-toolbar# settings.py增加如下内容INSTALLED_APPS.append('debug_toolbar',)MIDDLEWARE.append('debug_toolbar.middleware.Debug ...