File size: 1,599 Bytes
766e5f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702e55b
766e5f9
702e55b
 
 
 
 
766e5f9
 
 
 
 
 
 
 
 
 
f8df211
702e55b
 
 
 
 
 
 
f8df211
702e55b
 
766e5f9
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
# from flask import Flask, redirect, abort, request

# app = Flask(__name__)

# @app.route('/')
# def index():
#     return redirect('https://chat3.eqing.tech', code=302)

# @app.route('/<path:path>', methods=['GET', 'POST'])
# def redirect_all(path):
#     if 'create' in path or 'fd' in path or 'web' in path:
#         return redirect('http://127.0.0.1', code=301)
#     if request.method == 'POST':
#         return redirect('http://127.0.0.1', code=301)
#     return redirect('https://chat3.eqing.tech', code=302)

# if __name__ == '__main__':
#     app.run()

from flask import Flask, redirect, abort, request
import requests

app = Flask(__name__)

@app.route('/')
def index():
    # 添加调试信息
    try:
        # 先检查目标URL是否可访问
        response = requests.head('https://chat3.eqing.tech', timeout=5)
        print(f"Target server status: {response.status_code}")
    except Exception as e:
        print(f"Target server error: {e}")
        # 如果目标服务器不可达,可以返回错误页面或备用地址
        return f"目标服务器暂时不可用: {e}", 503
    
    return redirect('https://chat3.eqing.tech', code=302)

@app.route('/<path:path>', methods=['GET', 'POST'])
def redirect_all(path):
    if 'create' in path or 'fd' in path or 'web' in path:
        return redirect('http://127.0.0.1', code=301)
    if request.method == 'POST':
        return redirect('http://127.0.0.1', code=301)
    return redirect('https://chat3.eqing.tech', code=302)

if __name__ == '__main__':
    app.run(debug=True)  # 开启调试模式查看详细信息