Created
September 20, 2012 17:50
-
-
Save raa0121/3757348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!-*- coding: utf-8 -*- | |
import os | |
import json | |
import re | |
from flask import Flask | |
from flask import request | |
app = Flask(__name__) | |
@app.route('/',methods=['GET', 'POST']) | |
def hello(): | |
if request.method == 'GET': | |
return 'lingr:hi Bot(DiceBot)' | |
elif request.method =='POST': | |
req = json.loads(request.body) | |
for e in req['events']: | |
if e['message']: | |
m = e['message']['text'] | |
u = e['message']['text'] | |
if re.search('^hi',m): | |
return 'hi'+u | |
if __name__ == '__main__': | |
# Bind to PORT if defined, otherwise default to 5000. | |
port = int(os.environ.get('PORT', 5000)) | |
app.run(host='0.0.0.0', port=port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment