dixitramjendra commited on
Commit
30e2a89
·
1 Parent(s): bedb5f5

Fix backendStatus null error - add missing HTML element

Browse files
.env ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TELEGRAM_BOT_TOKEN=8574181955:AAE7OTQct0ZuCOsodaMj1npU09eywZrPDAQ
2
+ TELEGRAM_CHAT_ID=160134690
3
+ TELEGRAM_CATEGORIES=160134690:ALL
4
+
5
+ # ============================================
6
+ # EMAIL CONFIGURATION (for Feedback System)
7
+ # ============================================
8
+ # Your Gmail address (sender)
9
+ EMAIL_ADDRESS=
10
+
11
+ # Gmail App Password (NOT your regular password!)
12
+ # Get it from: https://myaccount.google.com/apppasswords
13
+ EMAIL_PASSWORD=
14
+
15
+ # SMTP Server settings (Gmail default)
16
+ SMTP_SERVER=smtp.gmail.com
17
+ SMTP_PORT=587
18
+
19
+ # Feedback recipient email
20
+ EMAIL_RECIPIENTS=biasbuster2026@gmail.com
__pycache__/visitor_tracker.cpython-312.pyc ADDED
Binary file (10.2 kB). View file
 
forex_macd_dashboard.html CHANGED
@@ -1356,6 +1356,8 @@
1356
  </div>
1357
 
1358
  <div class="last-updated" id="lastUpdated"></div>
 
 
1359
 
1360
  <!-- Help & FAQ Section -->
1361
  <section id="helpSection" class="help-section" style="display: none;">
 
1356
  </div>
1357
 
1358
  <div class="last-updated" id="lastUpdated"></div>
1359
+ <span id="backendStatus" style="color: var(--text-secondary); font-size: 0.8rem;">Backend:
1360
+ Checking...</span>
1361
 
1362
  <!-- Help & FAQ Section -->
1363
  <section id="helpSection" class="help-section" style="display: none;">
test_alert_hf.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test Alert System for Hugging Face - Injects a mock signal to trigger browser alert
4
+ """
5
+ import json
6
+ import os
7
+ from datetime import datetime
8
+
9
+ # Path to HF signals file
10
+ SIGNALS_FILE = "/home/ramram/Desktop/SELF_LEARNING/Medical RAG/documents/Signal/hf_deployment/forex_macd_signals.json"
11
+
12
+ def inject_mock_signal():
13
+ """Inject a new mock signal to test the alert system on HF"""
14
+
15
+ # Read current signals
16
+ with open(SIGNALS_FILE, 'r') as f:
17
+ data = json.load(f)
18
+
19
+ # Create a new mock signal
20
+ mock_signal = {
21
+ "instrument": "TEST/ALERT",
22
+ "flag": "🔔",
23
+ "ltp": 1.2345,
24
+ "daily": {"macd_line": 0.01, "bias": "BULLISH", "label": "1D Trend"},
25
+ "h4": {"histogram": 0.005, "bias": "BULLISH", "label": "4H MOM"},
26
+ "h1": {"histogram": 0.002, "status": "BULLISH_MOM", "close": 1.2345, "label": "1H Entry", "ema_200": 1.23, "rsi": 55},
27
+ "overall_status": "ACTIVE_BUY",
28
+ "signal": {
29
+ "type": "BUY",
30
+ "entry_price": 1.2345,
31
+ "sl": 1.2300,
32
+ "current_sl": 1.2300,
33
+ "tp1": 1.2400,
34
+ "tp2": 1.2450,
35
+ "tp3": 1.2500,
36
+ "tp_hits": [False, False, False],
37
+ "time": datetime.now().isoformat(),
38
+ "candle_time": datetime.now().isoformat(),
39
+ "category": "Forex"
40
+ },
41
+ "category": "Forex",
42
+ "timestamp": datetime.now().isoformat()
43
+ }
44
+
45
+ # Insert at the beginning
46
+ data['data'].insert(0, mock_signal)
47
+ data['last_updated'] = datetime.now().isoformat()
48
+ data['backend_heartbeat'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
49
+
50
+ # Save back
51
+ with open(SIGNALS_FILE, 'w') as f:
52
+ json.dump(data, f, indent=2)
53
+
54
+ print("✅ Mock signal injected: TEST/ALERT BUY")
55
+ print(" Entry: 1.2345, SL: 1.2300, TP1: 1.2400")
56
+ print("\n📢 Push to HF and refresh to test!")
57
+
58
+
59
+ def remove_mock_signal():
60
+ """Remove the mock signal"""
61
+ # Read current signals
62
+ with open(SIGNALS_FILE, 'r') as f:
63
+ data = json.load(f)
64
+
65
+ # Filter out test signals
66
+ data['data'] = [d for d in data['data'] if d['instrument'] != 'TEST/ALERT']
67
+ data['last_updated'] = datetime.now().isoformat()
68
+
69
+ # Save back
70
+ with open(SIGNALS_FILE, 'w') as f:
71
+ json.dump(data, f, indent=2)
72
+
73
+ print("✅ Mock signal removed from HF deployment")
74
+
75
+
76
+ if __name__ == "__main__":
77
+ import sys
78
+
79
+ if len(sys.argv) > 1 and sys.argv[1] == 'remove':
80
+ remove_mock_signal()
81
+ else:
82
+ inject_mock_signal()
test_visitor_email.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script to send visitor report email
4
+ Uses email configuration from user input
5
+ """
6
+
7
+ import sys
8
+ import os
9
+ from pathlib import Path
10
+
11
+ # Add current directory to path
12
+ sys.path.insert(0, str(Path(__file__).parent))
13
+
14
+ from daily_visitor_report import DailyVisitorReport
15
+
16
+ # Override email configuration
17
+ os.environ['EMAIL_ADDRESS'] = 'biasbuster2026@gmail.com'
18
+ os.environ['VISITOR_REPORT_EMAIL'] = 'biasbuster2026@gmail.com'
19
+
20
+ # Note: You need to set EMAIL_PASSWORD
21
+ # Get app password from: https://myaccount.google.com/apppasswords
22
+
23
+ if __name__ == "__main__":
24
+ print("=" * 60)
25
+ print("📧 Visitor Report Email Test")
26
+ print("=" * 60)
27
+ print()
28
+
29
+ # Check if password is set
30
+ if not os.getenv('EMAIL_PASSWORD'):
31
+ print("⚠️ EMAIL_PASSWORD not set!")
32
+ print()
33
+ print("To send emails, you need a Gmail App Password:")
34
+ print("1. Go to: https://myaccount.google.com/apppasswords")
35
+ print("2. Create an app password for 'Mail'")
36
+ print("3. Set it in .env file:")
37
+ print(" EMAIL_PASSWORD=your-16-char-app-password")
38
+ print()
39
+ print("Or set it temporarily:")
40
+ print(" export EMAIL_PASSWORD='your-app-password'")
41
+ print(" python3 test_visitor_email.py")
42
+ print()
43
+ sys.exit(1)
44
+
45
+ # Create and send report
46
+ report = DailyVisitorReport()
47
+
48
+ print(f"📧 Sending visitor report to: {report.email_to}")
49
+ print(f"📤 From: {report.email_from}")
50
+ print()
51
+
52
+ success = report.send_report()
53
+
54
+ if success:
55
+ print()
56
+ print("=" * 60)
57
+ print("✅ SUCCESS! Email sent successfully!")
58
+ print("=" * 60)
59
+ print()
60
+ print("Check your inbox: biasbuster2026@gmail.com")
61
+ else:
62
+ print()
63
+ print("=" * 60)
64
+ print("❌ FAILED! Could not send email")
65
+ print("=" * 60)
66
+ print()
67
+ print("Check the error messages above")