-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
67 lines (50 loc) · 1.45 KB
/
run.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from yowsuprestful.stack import QueueStack
from flask import Flask
from flask_restful import Resource, Api
from flask import request
import sys
app = Flask(__name__)
api = Api(app)
stack = QueueStack()
class getMessage(Resource):
def get(self):
message = stack.getMessage()
if not message:
message = {}
return message
class postMessage(Resource):
def get(self):
msg = request.args.get('msg', '')
number = request.args.get('number', '')
stack.sendMessage(number, msg)
message = {
"sended": "1"
}
return message
class postImageByPath(Resource):
def get(self):
path = request.args.get('path', '')
number = request.args.get('number', '')
stack.sendImage(number, path)
message = {
"sended": "1"
}
return message
class postImageBase64(Resource):
def get(self):
raise Exception("To Implement")
class postImageUrl(Resource):
def get(self):
raise Exception("To Implement")
api.add_resource(getMessage, '/')
api.add_resource(postMessage, '/postMessage')
api.add_resource(postImageByPath, '/postImageByPath')
api.add_resource(postImageBase64, '/postImageBase64')
api.add_resource(postImageUrl, '/postImageUrl')
if __name__ == '__main__':
args = sys.argv
user = args[1]
password = args[2]
# stack.sendMessage()
stack.start(user, password)
app.run(debug=True)