-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (32 loc) · 843 Bytes
/
app.py
File metadata and controls
38 lines (32 loc) · 843 Bytes
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
#!/usr/bin/env python
# coding=utf-8
from flask import request
from flask import Flask
import os
import json
from flask_httpauth import HTTPBasicAuth
from flask import json
app = Flask(__name__, static_url_path="/find/api")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'jmore':
return 'python'
return None
@app.route('/find/api', methods=['POST'])
@auth.login_required
def create_task():
if request.headers['Content-Type'] == 'text/plain':
return "Text Message: " + request.data
elif request.headers['Content-Type'] == 'application/json':
a = request.json
while (type(a) is dict):
a = a.values()[0]
if str(a[0]) == 'p':
return str(a)
else:
return '["'+ str(a[0])+'"]'
return str(a)
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')