|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from flask import Flask, redirect, abort, request |
|
|
import requests |
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
@app.route('/') |
|
|
def index(): |
|
|
|
|
|
try: |
|
|
|
|
|
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) |
|
|
|