ranar110 commited on
Commit
dfa77fb
Β·
1 Parent(s): bfe9dec

Force Docker rebuild to pick up static file changes

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. test_deployment.py +88 -0
Dockerfile CHANGED
@@ -12,6 +12,7 @@ ENV HOME=/home/user \
12
 
13
  WORKDIR $HOME/app
14
 
 
15
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
16
  COPY --chown=user . $HOME/app
17
 
 
12
 
13
  WORKDIR $HOME/app
14
 
15
+ # Force rebuild - updated static files (2026-02-02)
16
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
17
  COPY --chown=user . $HOME/app
18
 
test_deployment.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+
4
+ print("=" * 60)
5
+ print("COMPREHENSIVE API TESTING")
6
+ print("=" * 60)
7
+
8
+ base_url = "https://ranar118-voice-detection.hf.space"
9
+
10
+ # Test 1: Check if site is accessible
11
+ print("\n1. Testing root endpoint...")
12
+ try:
13
+ response = requests.get(f"{base_url}/", timeout=10)
14
+ print(f" βœ“ Status Code: {response.status_code}")
15
+ print(f" βœ“ Content-Type: {response.headers.get('content-type')}")
16
+ print(f" βœ“ Content Length: {len(response.content)} bytes")
17
+
18
+ # Check if the HTML contains the updated URL
19
+ if '/detect' in response.text and 'http://127.0.0.1:8000' not in response.text:
20
+ print(" βœ“ HTML has been updated with relative URL")
21
+ elif 'http://127.0.0.1:8000' in response.text:
22
+ print(" βœ— WARNING: HTML still contains localhost URL!")
23
+ else:
24
+ print(" ? Could not verify URL in HTML")
25
+ except Exception as e:
26
+ print(f" βœ— Error: {e}")
27
+
28
+ # Test 2: Test /detect endpoint with proper authentication
29
+ print("\n2. Testing /detect endpoint with API key...")
30
+ try:
31
+ headers = {"x-api-key": "my_secret_key_123"}
32
+ # Use a simple test without actual audio
33
+ response = requests.post(f"{base_url}/detect", headers=headers, timeout=10)
34
+ print(f" Status Code: {response.status_code}")
35
+ print(f" Response: {response.text[:200]}")
36
+
37
+ if response.status_code == 400:
38
+ print(" βœ“ API is responding (400 expected without audio file)")
39
+ elif response.status_code == 200:
40
+ print(" βœ“ API is working!")
41
+ else:
42
+ print(f" ? Unexpected status: {response.status_code}")
43
+ except Exception as e:
44
+ print(f" βœ— Error: {e}")
45
+
46
+ # Test 3: Test without API key (should fail with 403)
47
+ print("\n3. Testing /detect without API key (should fail)...")
48
+ try:
49
+ response = requests.post(f"{base_url}/detect", timeout=10)
50
+ print(f" Status Code: {response.status_code}")
51
+ if response.status_code == 403:
52
+ print(" βœ“ Authentication is working correctly")
53
+ else:
54
+ print(f" Response: {response.text[:200]}")
55
+ except Exception as e:
56
+ print(f" βœ— Error: {e}")
57
+
58
+ # Test 4: Check CORS headers
59
+ print("\n4. Checking CORS headers...")
60
+ try:
61
+ response = requests.options(f"{base_url}/detect", headers={
62
+ "Origin": "https://ranar118-voice-detection.hf.space",
63
+ "Access-Control-Request-Method": "POST"
64
+ }, timeout=10)
65
+ print(f" Status Code: {response.status_code}")
66
+ cors_headers = {k: v for k, v in response.headers.items() if 'access-control' in k.lower()}
67
+ if cors_headers:
68
+ print(f" CORS Headers: {cors_headers}")
69
+ else:
70
+ print(" ⚠ No CORS headers found (might need to add CORS middleware)")
71
+ except Exception as e:
72
+ print(f" βœ— Error: {e}")
73
+
74
+ # Test 5: Test /generate endpoint
75
+ print("\n5. Testing /generate endpoint...")
76
+ try:
77
+ response = requests.post(f"{base_url}/generate",
78
+ headers={"Content-Type": "application/json"},
79
+ json={"text": "test", "murf_api_key": "test", "voice_id": "test"},
80
+ timeout=10)
81
+ print(f" Status Code: {response.status_code}")
82
+ print(f" Response: {response.text[:200]}")
83
+ except Exception as e:
84
+ print(f" βœ— Error: {e}")
85
+
86
+ print("\n" + "=" * 60)
87
+ print("TESTING COMPLETE")
88
+ print("=" * 60)