mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +03:00
update
This commit is contained in:
parent
1c5ce6d88b
commit
98965b08ae
File diff suppressed because one or more lines are too long
@ -35,17 +35,57 @@ def redirect_to_index():
|
||||
|
||||
CORS(app, resources={r"/*": {"origins": "*"}})
|
||||
|
||||
|
||||
## !!!!!!!!!!! COLABのプロキシがRoot直下のパスしか通さない??? !!!!!!
|
||||
## !!!!!!!!!!! Bodyで参照、設定コマンドを代替する。 !!!!!!
|
||||
@app.route('/api', methods=['POST'])
|
||||
def api():
|
||||
try:
|
||||
print("POST REQUEST PROCESSING....\n")
|
||||
command = request.json['command']
|
||||
print(request)
|
||||
# filename = f"{prefix}{index:03}.zip"
|
||||
filename = f"AAAAAAAAAAA.zip"
|
||||
data_dir = os.path.join(DATA_ROOT)
|
||||
|
||||
# GET VOICE
|
||||
if command == "GET_VOICE":
|
||||
title = request.json['title']
|
||||
prefix = request.json['prefix']
|
||||
index = request.json['index']
|
||||
|
||||
data_dir = os.path.join(DATA_ROOT, title)
|
||||
os.makedirs(data_dir,exist_ok=True)
|
||||
|
||||
filename = f"{prefix}{index:03}.zip"
|
||||
fullpath = os.path.join(data_dir, filename)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
# POST VOICE
|
||||
if command == "POST_VOICE":
|
||||
title = request.json['title']
|
||||
prefix = request.json['prefix']
|
||||
index = request.json['index']
|
||||
data = base64.b64decode(request.json['data'])
|
||||
|
||||
data_dir = os.path.join(DATA_ROOT, title)
|
||||
os.makedirs(data_dir,exist_ok=True)
|
||||
|
||||
filename = f"{prefix}{index:03}.zip"
|
||||
fullpath = os.path.join(data_dir, filename)
|
||||
f = open(fullpath, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user