from flask import Flask, Response, request import requests app = Flask(__name__) @app.route('/') def index(): html_content = ''' TON Connect

Подключение к TON

Статус: не подключено
Баланс: —
''' return Response(html_content, mimetype='text/html') @app.route('/get_balance') def get_balance(): address = request.args.get('address') if not address: return {'error': 'No address provided'}, 400 try: res = requests.get(f'https://tonapi.io/v2/accounts/{address}') data = res.json() raw_balance = int(data.get('balance', 0)) ton_balance = raw_balance / 1e9 return {'balance': round(ton_balance, 4)} except: return {'error': 'failed to fetch'}, 500 if __name__ == '__main__': app.run(host='0.0.0.0', port=7860)