Spaces:
Running
Running
| from flask import Flask, request, jsonify, make_response | |
| from baseline import fix_commas, create_baseline_pipeline | |
| import logging | |
| app = Flask(__name__) | |
| logger = logging.Logger(__name__) | |
| logging.basicConfig(level=logging.INFO) | |
| def root(): | |
| return ("Welcome to the comma fixer. Send a POST request to /fix-commas or /baseline/fix-commas with a string " | |
| "'s' in the JSON body to try " | |
| "out the functionality.") | |
| def fix_commas_with_baseline(): | |
| data = request.get_json() | |
| if 's' in data: | |
| return make_response(jsonify({'s': fix_commas(app.baseline_pipeline, data['s'])}), 200) | |
| else: | |
| return make_response("Parameter 's' missing", 400) | |
| if __name__ == '__main__': | |
| logger.info("Loading the baseline model.") | |
| app.baseline_pipeline = create_baseline_pipeline() | |
| app.run(debug=True) | |