-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocker.py
35 lines (32 loc) · 921 Bytes
/
mocker.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
# -*- coding:utf-8 -*-
from flask import abort, jsonify, Flask, request, Response
import json
app = Flask(__name__)
success = {
"error_code": 0,
"error_msg": "success",
"result": "0xabc"
}
error = {
"error_code": 1,
"error_msg": "params is not correctly",
"result": ""
}
@app.route("/handle_data", methods=['POST'])
def handle_data():
body = trans(request.get_data())
if not body.get("method") in ["base16","base32","base58","base64"]:
return error
if body.get("payload") == None:
return error
return success
'''pretty json '''
def trans(payload):
try:
return json.loads(str(payload, "utf-8"))
# return json.dumps(a_json, sort_keys=True, indent=4, separators=(',', ':'))
except:
print("error when parsing payload")
return payload
if __name__ == "__main__":
app.run(host = "127.0.0.1",port = 6660,debug = True)