1.FBV方式:添加验证装饰器 def auth(func): def deco(request, *args, **kwargs): u = request.get_signed_cookie('username', salt='user', default=None) if not u: return render(request, 'login.html') return func(request, *args, **kwargs) return deco @authdef index(r…
转自http://blog.csdn.net/jobschen/article/details/52823980 mac ssh登录linux服务器 的两种方式: 个人推荐第二种,zsh方式,只需要把公钥copy到目标服务器,设置别名就可以全用,方便快捷. 一. 使用item2的profiles 和expect脚本 配置步骤: 1. 写一个expect脚本 #!/usr/bin/expect set timeout 30 spawn ssh [lindex $argv 0]@[lindex $a…
cmd窗口使用sftp命令非密钥和密钥登录SFTP服务器的两种方式 一.在Windows环境下搭建SFTP服务器可参见http://www.cnblogs.com/Kevin00/p/6341295.html 二.非密钥登录 0.Bitvise SSH Server服务器 1.Win + R 进入cmd窗口. 2.登录命令:sftp -P 28 kevin@127.0.0.1 说明:-P 端口参数 28是端口,默认端口是22   kevin是登录的用户名,127.0.0.1是SFTP服务器的地址…
一.csrf攻击 1.1 csrf攻击(跨站请求伪造) [csrf攻击即]:通过第3方网站,伪造请求(前提条件是你已经登录正常网站,并保存了session或cookie登录信息且没有退出),第三方网站即可通过你的session或cookie直接修改正常网站的用户名密码. 首先做一个登录页,让用户输入用户名和密码进行登录,登录成功之后跳转的修改密码页面.在修改密码页面输入新密码,点击确认按钮完成密码修改. 登录页需要一个模板文件login.html.修改密码页面也需要一个模板文件change_pw…
上一篇文章介绍了 装饰器的概念.现在讲一下在程序中怎么来写装饰器.上代码: def X(fun): def Y(b): print(b) fun() return Y def test(): print('OK') test = X(test) test(1) 前五行是一个闭包,因为内层函数的参数是外层函数的变量,而外层函数返回了内存函数的引用. 第10行,在调用函数X时,将函数test的引用(注意不是test(),没有小括号)作为参数传入,此时X(test)返回的是 Y函数的引用.所以第十行的…
Java Session 介绍 一.添加.获取session 1.项目结构 2.jar包 3.web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns…
来个简单的装饰器 def cached_method_result(fun): """方法的结果缓存装饰器""" @wraps(fun) def inner(self, *args, **kwargs): if not hasattr(fun, 'result'): result = fun(self, *args, **kwargs) fun.result = result fun_name = fun.__name__ setattr(sel…
为TaskSet声明任务的典型方法是使用task装饰器.该min_wait和MAX_WAIT属性也可以在使用taskset类中重写. from locust import Locust, TaskSet, task class MyTaskSet(TaskSet): min_wait = 5000 max_wait = 15000 @task(1) def my_taskone(self): print("executing my_task one") @task(3) def my_…
拦截器是个好东西,之前用到过,现在记录一下,供以后参考使用! 其一,使用org.aspectj.lang.annotation.Aspect 先上代码: package com.test.interceptors.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Around;…
根据别人发布整理,个人爱好收集(原文:https://blog.csdn.net/mydistance/article/details/83958655 ) 第一种:定义函数装饰器,在函数,类中使用函数装饰器 一.定义视图类 定义类视图,且类视图继承自View(举例) from django.views.generic import View class DemoView(View): """ 具体的视图函数 """ 定义路由: urlpatte…