-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
65 lines (44 loc) · 1.35 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
# -*- coding: utf-8 -*-
# Copyright © yqh
# CreateTime: 2019-12-26 11:01:11
from flask import Flask, Blueprint, jsonify, request, render_template
from flask_script import Manager
from run_main import RunMain
users_blueprint = Blueprint('interface', __name__, template_folder='testResult')
class BaseConfig(object):
DEBUG = False
TESTING = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = 'CazzEqyQDBjm'
class DevConfig(BaseConfig):
DEBUG = True
configs = {
'dev': DevConfig,
}
def create_app():
api = Flask(__name__)
api_settings = configs['dev']
api.config.from_object(api_settings)
api.register_blueprint(users_blueprint)
return api
@users_blueprint.route('/ping', methods=['GET'])
def ping_pong():
return jsonify({'status': 'success', 'message': 'auto-interface testing'})
@users_blueprint.route('/ret', methods=['get'])
def ret():
return render_template('result.html')
@users_blueprint.route('/run', methods=['POST'])
def run_case():
r = RunMain()
run_ret = r.run()
if run_ret:
ret_data = {'status': 'success', 'message': '用例成功'}
code = 200
else:
ret_data = {'status': 'failed', 'message': '执行失败'}
code = 400
return jsonify(ret_data), code
api = create_app()
if __name__ == '__main__':
manager = Manager(api)
manager.run()