Skip to content

Instantly share code, notes, and snippets.

@raa0121
Created September 20, 2012 17:50
Show Gist options
  • Save raa0121/3757348 to your computer and use it in GitHub Desktop.
Save raa0121/3757348 to your computer and use it in GitHub Desktop.
#!-*- 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