from flask import Flask, render_template_string, request, jsonify from flask_cors import CORS import requests import json app = Flask(__name__) CORS(app) # API base URL - use environment variable for Docker Compose import os API_BASE_URL = os.getenv('API_BASE_URL', 'http://localhost:3000') print("API: ", API_BASE_URL) # Beautiful HTML template with modern styling HTML_TEMPLATE = """ CM Bot Database Viewer

CM Bot Database Viewer

Real-time view of accounts and users data

Loading accounts...

""" @app.route('/') def index(): return render_template_string(HTML_TEMPLATE) @app.route('/api/acc/') def proxy_acc(): try: response = requests.get(f"{API_BASE_URL}/acc/") return jsonify(response.json()) except Exception as e: return jsonify({"error": str(e)}), 500 @app.route('/api/user/') def proxy_user(): try: response = requests.get(f"{API_BASE_URL}/user/") return jsonify(response.json()) except Exception as e: return jsonify({"error": str(e)}), 500 @app.route('/api/update-acc-data', methods=['POST']) def proxy_update_acc(): try: data = request.get_json() response = requests.post(f"{API_BASE_URL}/update-acc-data", json=data) return jsonify(response.json()), response.status_code except Exception as e: return jsonify({"error": str(e)}), 500 @app.route('/api/update-user-data', methods=['POST']) def proxy_update_user(): try: data = request.get_json() response = requests.post(f"{API_BASE_URL}/update-user-data", json=data) return jsonify(response.json()), response.status_code except Exception as e: return jsonify({"error": str(e)}), 500 if __name__ == '__main__': print("Starting CM Web View...") print("Web interface will be available at: http://localhost:8000") print("Make sure the API server is running on port 3000") app.run(host='0.0.0.0', port=8000, debug=True)