| import requests | |
| from flask import Flask, Response, request | |
| app = Flask(__name__) | |
| TARGET_SERVER = "http://23.237.104.106:8080" | |
| HEADERS = { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", | |
| "Referer": "http://23.237.104.106:8080/" | |
| } | |
| def proxy_stream(stream_path): | |
| url = f"{TARGET_SERVER}/{stream_path}" | |
| # Gửi request sang server gốc kèm Header xịn | |
| resp = requests.get(url, headers=HEADERS, stream=True) | |
| # Trả trực tiếp dữ liệu về cho App IPTV | |
| headers = [(name, value) for (name, value) in resp.raw.headers.items() | |
| if name.lower() not in ['content-encoding', 'content-length', 'transfer-encoding', 'connection']] | |
| headers.append(('Access-Control-Allow-Origin', '*')) # Cho phép app TV tải không bị chặn CORS | |
| return Response(resp.content, resp.status_code, headers) | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) |