From 07595fd0600efa1836050ea6cd0417a345358408 Mon Sep 17 00:00:00 2001 From: wataru Date: Wed, 14 Sep 2022 07:19:02 +0900 Subject: [PATCH] update --- docs/recorderServer.py | 84 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/docs/recorderServer.py b/docs/recorderServer.py index b5ee18aa..a03e37c8 100644 --- a/docs/recorderServer.py +++ b/docs/recorderServer.py @@ -98,55 +98,51 @@ def api(): print(traceback.format_exc()) return str(e) -@app.route('/api/voice///', methods=['POST']) -def post_voice(title, prefix, index): - try: - filename = f"{prefix}{index:03}.zip" - data_dir = os.path.join(DATA_ROOT, title) - os.makedirs(data_dir,exist_ok=True) - fullpath = os.path.join(data_dir, filename) - data = base64.b64decode(request.json['data']) - f = open(fullpath, 'wb') - f.write(data) - f.close() - data = { - "message":"OK" - } - return jsonify(data) - except Exception as e: - print("REQUEST PROCESSING!!!! EXCEPTION!!!", e) - print(traceback.format_exc()) - return str(e) -@app.route('/api/voice///', methods=['GET']) -def get_voice(title, prefix, index): - filename = f"{prefix}{index:03}.zip" - data_dir = os.path.join(DATA_ROOT, title) - fullpath = os.path.join(data_dir, filename) +## !!!!!!!!!!! COLABのプロキシがRoot直下のパスしか通さない??? !!!!!! +## !!!!!!!!!!! Bodyで参照、設定コマンドを代替する。 !!!!!! +# @app.route('/api/voice///', methods=['POST']) +# def post_voice(title, prefix, index): +# try: +# filename = f"{prefix}{index:03}.zip" +# data_dir = os.path.join(DATA_ROOT, title) +# os.makedirs(data_dir,exist_ok=True) +# fullpath = os.path.join(data_dir, filename) +# data = base64.b64decode(request.json['data']) +# f = open(fullpath, 'wb') +# f.write(data) +# f.close() +# data = { +# "message":"OK" +# } +# return jsonify(data) +# except Exception as e: +# print("REQUEST PROCESSING!!!! EXCEPTION!!!", e) +# print(traceback.format_exc()) +# return str(e) - is_file = os.path.isfile(fullpath) - if is_file == False: - data = { - "message":"NOT_FOUND", - } - return jsonify(data) +# @app.route('/api/voice///', methods=['GET']) +# def get_voice(title, prefix, index): +# filename = f"{prefix}{index:03}.zip" +# data_dir = os.path.join(DATA_ROOT, title) +# fullpath = os.path.join(data_dir, filename) - f = open(fullpath, 'rb') - data = f.read() - dataBase64 = base64.b64encode(data).decode('utf-8') - data = { - "message":"OK", - "data":dataBase64, - } - return jsonify(data) +# is_file = os.path.isfile(fullpath) +# if is_file == False: +# data = { +# "message":"NOT_FOUND", +# } +# return jsonify(data) +# f = open(fullpath, 'rb') +# data = f.read() +# dataBase64 = base64.b64encode(data).decode('utf-8') +# data = { +# "message":"OK", +# "data":dataBase64, +# } +# return jsonify(data) -# @app.after_request -# def after_request(response): -# # response.headers.add('Access-Control-Allow-Origin', '*') -# response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization') -# response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS') -# return response if __name__ == '__main__':