File size: 1,709 Bytes
bab9c3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from app import app
from flask import render_template, request, jsonify
import utils.globals as globals
from utils.globals import *
from utils.tools import *






# GPT 主页路由
@app.route('/chatgpt', methods=['GET', 'POST'])
@admin_required
def chatgpt():

    if request.method == 'GET':
        # 加载并显示 chatToken.json 文件中的内容
        return render_template('GPT.html', retokens=globals.chatToken)

    if request.method == 'POST':
        # 获取更新后的 retoken 数据
        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
        
# Claude 主页路由
@app.route('/claude', methods=['GET', 'POST'])
@admin_required
def claude():

    if request.method == 'GET':
        # 加载并显示 chatToken.json 文件中的内容
        return render_template('claude.html', retokens=globals.cluadeToken)

    if request.method == 'POST':
        # 获取更新后的 cltoken 数据
        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