一些思路和想法

Django 启用 https 支持

有两种方案。

  1. 用stunnel

安装
sudo apt-get install stunnel4

生成证书

1
2
3
# openssl req -new -x509 -days 365 -nodes -out vpsee.pem -keyout vpsee.pem

# chmod 600 vpsee.pem

新建配置文件 dev_https

1
2
3
4
5
6
7
8
9
10
11
# vi https
pid =
cert = vpsee.pem
debug = 7
foreground = yes

[https]
accept = 443
connect = 8000

# stunnel https

启动

1
2
stunnel dev_https
HTTPS=on python manage.py runserver 8003

  1. 用 django-sslserver
    安装
    pip install django-sslserver

在 INSTALLED_APPS 里增加

1
2
3
4
INSTALLED_APPS = (...
"sslserver",
...
)

运行
python manage.py runsslserver --certificate /path/to/certificate.crt --key /path/to/key.key

参考资料

https://www.ianlewis.org/en/testing-https-djangos-development-server
https://github.com/teddziuba/django-sslserver

git 搜索历史文件中出现的字符串

git log -S/-G/--all

  • -S 字符串方式查找改变了行数的不同的地方
  • -G 正则的方式匹配所有的改变

git log -Sbar -- foo.rb

在 foo.rb 文件中搜所有的历史

django 默认的模板引擎没有模板注入

但是模板中的 load 功能可以载入服务器上python文件?

php 中 random 连续使用可能造成随机数预测

分享到 评论