linux python环境
1、安装 pip install web.py
2、新建hook.py
3、vim hook.py 编辑
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import web
import os
urls = (
'/', 'index'
)
app = web.application(urls, globals())
class index:
def POST(self):
os.system('cd /home/wwwroot/dnmp/www/grazy_saas_dev && git stash && git pull')
return "python post hook!"
if __name__ == "__main__":
app.run()
4、后台运行
nohup python hook.py > out.log &
指定端口 python hook.py 8080
nohup python hook.py 8080 > out.log &
5、访问 http://ip 或 http://ip:8080
6、配置地址到码云webhook