示例#1
0
__author__ = 'Veon'

from notiflask import app

if __name__ == "__main__":
    app.run(debug=True)
示例#2
0
文件: hello.py 项目: veonua/notiflask
    return render_template("user.html", login=not session.get('userId'), own=(str(user.pk) == session.get('userId')),
                           email=user.email.lower(),
                           devices=user.devices, glassConnected=Glass.has_glass_connected(user))


@app.route('/github/<uid>', methods=['POST'])
def github_hook(uid):
    payload = json.loads(request.form['payload'])
    name = payload['pusher']['name'] + "(" + payload['pusher']['email'] + ")"
    uri = payload['repository']['url']
    reponame = payload['repository']['name']
    commits = payload['commits']
    cnum = len(commits)
    if cnum == 1:
        text = commits[0]["message"]
    else:
        text = str(cnum) + " commits"

    branch = payload['ref']

    data = {'title': name,
            'text': text + " in " + branch + " " + reponame,
            'canonicalUrl': uri}

    send(uid, data)
    return Response(status=204)


if __name__ == '__main__':
    app.run()