forked from cooltoast/internet-cucumber
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
42 lines (35 loc) · 1.17 KB
/
app.py
File metadata and controls
42 lines (35 loc) · 1.17 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask, request
import config
import json
import requests
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/cucumber')
def cucumber():
return 'welcome to internet cucumber'
@app.route('/cucumber/yo')
def yo():
yo_all_request = requests.post("http://api.justyo.co/yoall/", data={'api_token': config.YO_API_TOKEN})
if 'result' in yo_all_request.json() and yo_all_request.json()['result'] == 'OK':
return json.dumps({'text': 'Yo sent to all!'})
else:
return json.dumps({'text': 'Error sending Yo. API may be down...'})
@app.route('/cucumber/venmo')
def venmo():
pay = {}
pay['access_token'] = config.VENMO_API_TOKEN
pay['email'] = config.venmo_email
pay['note'] = 'sent from cucumber'
pay['amount'] = request.args['amount']
url = 'https://api.venmo.com/v1/payments'
resp = requests.post(url, pay)
if 'error' in resp.json():
return str(resp.json()['error']['message'])
elif 'data' in resp.json():
return str(resp.json()['data']['payment']['status'])
else:
return 'wat'
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)