def init(self): if self.db_name is not None and self.db_user is not None and self.db_pass is not None: self.db = DbGateway(self.db_engine, self.db_host, self.db_name, self.db_user, self.db_pass) else: db_name, db_user, db_pass = self.ui.dialog_init( self.default_db_name, self.default_db_user, self.default_db_pass) self.db = DbGateway(self.db_engine, self.db_host, db_name, db_user, db_pass)
from flask import Flask, request, jsonify, make_response from flask_cors import CORS, cross_origin from db import DbGateway from decorators import ensure_json, ensure_key, handle_options_method app = Flask(__name__) CORS(app, origins=['http://*****:*****@app.route('/health', methods=['GET', 'OPTIONS']) @handle_options_method def health(): return make_response() @app.route('/question', methods=['POST', 'OPTIONS']) @handle_options_method @ensure_json @ensure_key('question') def post_question(): data = request.get_json() if len(data['question']) > QUESTION_LENGTH_LIMIT: return make_response(jsonify(message="'question' value is too long."), 422)