LLMs / app.py
sanbo1200's picture
Update app.py
766e5f9 verified
# 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) # 开启调试模式查看详细信息