Spaces:
Sleeping
Sleeping
File size: 997 Bytes
5760b44 a5fed35 5760b44 a5fed35 5760b44 35c0239 5760b44 b1106e6 5760b44 b1106e6 5760b44 b1106e6 5760b44 a5fed35 |
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 |
from flask import Flask, request, jsonify, make_response
from src.baseline import fix_commas, create_baseline_pipeline
import logging
logger = logging.Logger(__name__)
logging.basicConfig(level=logging.INFO)
app = Flask(__name__)
logging.info('Loading the baseline model...')
app.baseline_pipeline = create_baseline_pipeline()
@app.route('/', methods=['GET'])
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.")
@app.route('/baseline/fix-commas/', methods=['POST'])
def fix_commas_with_baseline():
json_field_name = 's'
data = request.get_json()
if json_field_name in data:
return make_response(jsonify({json_field_name: fix_commas(app.baseline_pipeline, data['s'])}), 200)
else:
return make_response(f"Parameter '{json_field_name}' missing", 400)
if __name__ == '__main__':
app.run(debug=True)
|