from flask import Flask, request from tool import runtool import yaml import os app = Flask(__name__) with open('config.yml', 'r') as file: config = yaml.load(file, Loader=yaml.FullLoader) env = os.getenv('FLASK_ENV', 'development') app.config.update(config['default']) if env in config: app.config.update(config[env]) @app.route('/') def hello_world(): # put application's code here return 'Hello World!' @app.route('/models', methods=['GET']) def getModels(): models = ['lexnet-cifar10', 'lenet5-fashion-mnist', 'fashion2', 'svhn', 'lenet5-mnist', 'alexnet-cifar10', 'mobilenet.1.00.224-imagenet', 'vgg16-imagenet'] return models @app.route('/run', methods=['POST']) def run(): data = request.get_json() exp = data['exp'] mutate_num = data['mutate_num'] root_dir = app.config['root_dir'] output_dir = app.config['output_dir'] config_name = app.config['config_name'] data = runtool(exp, root_dir, output_dir, config_name, mutate_num) print(data) return data if __name__ == '__main__': app.run()