![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python web开发实战
github_38596081
这个作者很懒,什么都没留下…
展开
-
Flask-Login的信号和应用
安装blinker、flask_loginpip install -i https://pypi.tuna.tsinghua.edu.cn/simple flask_loginpip install -i https://pypi.tuna.tsinghua.edu.cn/simpleblinkeruser_logged_in是signal实例创建login_manag...原创 2019-08-13 15:21:33 · 173 阅读 · 0 评论 -
3 Flask Web--在flask_sqlalchemy中记录慢查询
config.py:class Config(object): ... DATABASE_QUERY_TIMEOUT = 0.0001 ##记录执行时间超过 0.0001秒的 SQLALCHEMY_RECORD_QUERIES = Truewsgi.py:from flask import abort, request, _app_ctx_stack, js...原创 2019-08-18 13:15:19 · 542 阅读 · 1 评论 -
4 Flask进阶---werkzeug的使用
密码加密models.pyconfig.pyclass Config(object): #JWT JWT_AUTH_HEADER_PREFIX = 'Bearer' # JWT_EXPIRATION_DELTA = timedelta(hours=12) # JWT_AUTH_URL_RULE = '/auth', # sql查詢 ...原创 2019-08-23 10:17:16 · 1256 阅读 · 0 评论 -
4 Flask开发进阶:记下一次级联删除的报错:Cannot delete or update a parent row: a foreign key constraint fails
中间表class Permission(object): LOGIN = 0x01 EDITOR = 0x02 OPERATOR = 0x04 ADMINISTER = 0xff PERMISSION_MAP = { LOGIN: ('login', 'Login user'), EDITOR: ('editor', '...原创 2019-08-31 12:39:49 · 570 阅读 · 1 评论 -
6 网站架构---mongo使用
models_mongo.py:创建数据库、集合、model# coding=utf-8import osimport uuidimport magicimport urllibfrom datetime import datetimeimport cropresize2import short_urlfrom PIL import Imagefrom flask impo...原创 2019-08-31 17:16:10 · 141 阅读 · 0 评论 -
9 消息队列和Celery
https://blog.csdn.net/yexiaomodemo/article/details/804734111、Rabbit MQLinux 安装Centos7Yum安装socat # yum -y install socat下载erlang软件包,本文使用erlang-19.0.4版本,下面给出下载链接# wgethttp://www.rabbitmq.co...原创 2019-09-02 21:55:37 · 139 阅读 · 0 评论 -
9 消息队列和Celery
原创 2019-09-03 20:35:23 · 103 阅读 · 0 评论 -
10 服务化
python3.7安装thriftpy报错:python3.6部署就没有问题定义服务calc.thriftservice CalcService { i64 add(1:i64 a, 2:i64 b),}server_with_thriftpy.py# coding=utf-8import osimport loggingimport...原创 2019-09-04 13:44:28 · 76 阅读 · 0 评论 -
13 python并发编程
单线程切换到多线程版本的思路:多线程的数据是共享的,使用Queue是线程安全的。多线程config.py# coding=utf-8import rePROXY_SITES = [ 'http://cn-proxy.com', 'http://www.xicidaili.com', 'http://www.kuaidaili.com/f...原创 2019-09-04 20:11:47 · 100 阅读 · 0 评论 -
3 flask web开发的redirect、url_for
D:\shen\python\PythonWebDev\web_develop\vpp_agent_dev\agent\source\app\views\ik_user_view.pyredirect(url_for("user.index"))from flask import Blueprintfrom werkzeug.wrappers import Response# ...原创 2019-08-17 13:45:00 · 286 阅读 · 0 评论 -
待完成
-- 查看系统用户select Host,User,Password from mysql.user;-- 创建一个远程用户create user test identified by '123456';-- 分配权限grant all privileges on *.* to 'test'@'%'identified by '123456' with grant option...原创 2019-08-12 20:52:14 · 228 阅读 · 0 评论 -
实现带有权限验证的文件托管服务
用户表和角色表是多对多的关系,需要定义一个用于关系的中间表,对于这种表强烈建议不要使用模型,而采用一个实际的表:roles_users = db.Table( 'roles_users', db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('role...原创 2019-08-13 17:57:11 · 137 阅读 · 0 评论 -
pip镜像源使用临时与永久设置方法
指定doubanpip3 install -r requirements.txt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com临时使用可以在使用pip的时候加参数-ihttps://pypi.tuna.tsinghua.edu.cn/simple例如:pip install -iht...原创 2019-08-18 16:11:30 · 2442 阅读 · 0 评论 -
Flask-Migrate使用
迁移脚本初始化迁移工作、修改表结构、创建迁移脚本注意事项更新数据库效果:如果和预想不一样,可以取消迁移操作,不用跑路了验证一下:实例:0、指定app_migrate.py的数据库配置和映射表的model1、初始化(如果有migrations文件,需要提前删除)2、添加、修改表或者字段(model文件中一定要导入:fr...原创 2019-08-13 21:08:51 · 105 阅读 · 0 评论 -
待完成 14 python进阶
用好标准库的模块errno通过系统errno精准捕获异常内容>>> import os>>> os.kill(12345, 0)Traceback (most recent call last): File "<stdin>", line 1, in <module>ProcessLookupError: [E...原创 2019-08-14 11:50:45 · 191 阅读 · 0 评论 -
带完成--Flask-Security
原创 2019-08-15 09:53:48 · 283 阅读 · 0 评论 -
web开发前的准备--vagrant+python3.7虚拟环境+autoenv
0、部署vagrant安装vagrant,直接到官网下载对应平台的vagrant,如果嫌慢就用下面的连接下载https://c4ys.com/archives/1230我使用的是centos7下载完了放到项目目录下D:\shen\vagrant\vmλ lsVagrant-CentOS-7.box Vagrantfile下载后的使用方法添加vagrant box...原创 2019-08-11 16:38:47 · 329 阅读 · 0 评论 -
6 网站架构
------------------------------Traceback (most recent call last): File "chapter6/section8/example_pymongo.py", line 111, in <module> db.system_js.insert_one({"_id": "mapper", "value": map...原创 2019-08-24 15:47:28 · 227 阅读 · 0 评论 -
自定义的定时器获取函数执行时间
获取函数执行时间的装饰器def log_execution_time(func): @wraps(func) def wrapper(*args, **kwargs): start = time.perf_counter() res = func(*args, **kwargs) end = time.perf_counter(...原创 2019-08-15 16:06:27 · 354 阅读 · 0 评论 -
3 Flask Web开发:记一次flask模板渲染实践
参考文档:https://flask.palletsprojects.com/en/1.0.x/blueprints/目录结构:(vpp_agent_venv3.7) [root@localhost source]# tree .├── app│ ├── __init__.py│ ├── views│ │ ├── ik_agent_view.py│...原创 2019-09-09 11:16:54 · 424 阅读 · 0 评论