|
|
from app import app
|
|
|
from flask import render_template, request, jsonify
|
|
|
import utils.globals as globals
|
|
|
from utils.globals import *
|
|
|
from utils.tools import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/chatgpt', methods=['GET', 'POST'])
|
|
|
@admin_required
|
|
|
def chatgpt():
|
|
|
|
|
|
if request.method == 'GET':
|
|
|
|
|
|
return render_template('GPT.html', retokens=globals.chatToken)
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
globals.chatToken = request.json.get('retokens')
|
|
|
|
|
|
|
|
|
if globals.chatToken:
|
|
|
save_retoken(globals.chatToken)
|
|
|
return jsonify({"status": "success", "message": "chatToken.json 已更新!"}), 200
|
|
|
else:
|
|
|
return jsonify({"status": "error", "message": "无效的数据格式!"}), 400
|
|
|
|
|
|
|
|
|
@app.route('/claude', methods=['GET', 'POST'])
|
|
|
@admin_required
|
|
|
def claude():
|
|
|
|
|
|
if request.method == 'GET':
|
|
|
|
|
|
return render_template('claude.html', retokens=globals.cluadeToken)
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
globals.cluadeToken = request.json.get('cltokens')
|
|
|
|
|
|
|
|
|
if globals.cluadeToken:
|
|
|
save_cltoken(globals.cluadeToken)
|
|
|
return jsonify({"status": "success", "message": "claudeToken.json 已更新!"}), 200
|
|
|
else:
|
|
|
return jsonify({"status": "error", "message": "无效的数据格式!"}), 400
|
|
|
|