-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_embedding.py
More file actions
75 lines (58 loc) · 2.48 KB
/
test_embedding.py
File metadata and controls
75 lines (58 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
"""
Test script to verify embedding functionality
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from flask import Flask
from app import app
import threading
import time
import requests
def test_embedding():
"""Test the embedding functionality"""
print("Testing Oversight AI Embedding Functionality")
print("=" * 50)
# Start the Flask app in a separate thread
def run_app():
app.run(host='0.0.0.0', port=12001, debug=False, use_reloader=False)
server_thread = threading.Thread(target=run_app, daemon=True)
server_thread.start()
# Wait for server to start
time.sleep(3)
# Test endpoints
endpoints = [
('/', 'Main Interface'),
('/embed', 'Embeddable Interface'),
('/embed/minimal', 'Minimal Embeddable Interface'),
('/api/report-types', 'API - Report Types')
]
base_url = 'http://localhost:12001'
for endpoint, description in endpoints:
try:
response = requests.get(f"{base_url}{endpoint}", timeout=5)
status = "✅ PASS" if response.status_code == 200 else f"❌ FAIL ({response.status_code})"
print(f"{status} - {description}: {endpoint}")
if endpoint == '/api/report-types' and response.status_code == 200:
data = response.json()
print(f" Available report types: {data.get('report_types', [])}")
except Exception as e:
print(f"❌ FAIL - {description}: {endpoint} - Error: {str(e)}")
print("\n" + "=" * 50)
print("Embedding Features:")
print("✅ CORS enabled for cross-origin embedding")
print("✅ X-Frame-Options set to ALLOWALL for iframe embedding")
print("✅ Multiple embedding interfaces available")
print("✅ Responsive design for different screen sizes")
print("✅ API endpoints accessible from embedded versions")
print("\nEmbedding URLs:")
print(f"📱 Standard Embed: {base_url}/embed")
print(f"📱 Minimal Embed: {base_url}/embed/minimal")
print(f"📚 Embedding Guide: {base_url}/embed/guide")
print("\nSample Iframe Code:")
print(f'<iframe src="{base_url}/embed" width="600" height="500" frameborder="0"></iframe>')
print("\n🎉 Embedding functionality is ready!")
print("You can now embed Oversight AI into any website using the iframe codes above.")
if __name__ == "__main__":
test_embedding()