blob: c6c9faf7d98e8bd618524226207af7dfce7f0a71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from flask import Flask, jsonify, request
from xkcd import get_xkcd
app = Flask(__name__)
app.config.from_envvar('CONF')
@app.route("/echo", methods=['POST'])
def echo():
d = {'response_type': 'in_channel',
'text': "I'm the echo bot!",
'attachments': [
{'text':request.form['text']}
]
}
return jsonify(d)
@app.route("/xkcd", methods=['POST'])
def xkcd_view():
title, url = get_xkcd(request.form['text'])
d = {'response_type': 'in_channel',
'text': title,
'attachments': [
{'image_url':"http:{0}:".format(url)}
]
}
return jsonify(d)
if __name__=="__main__":
app.run()
|