Internal
Public Access
Update debug endpoint to show User-Agent detection in HTML
This commit is contained in:
+30
-10
@@ -1,20 +1,40 @@
|
|||||||
"""Debug views for troubleshooting mobile app."""
|
"""Debug views for troubleshooting mobile app."""
|
||||||
|
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse, HttpResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.views.decorators.http import require_http_methods
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
@require_http_methods(["GET", "POST"])
|
||||||
def debug_user_agent(request):
|
def debug_user_agent(request):
|
||||||
"""Return the User-Agent header for debugging mobile app."""
|
"""Return the User-Agent header for debugging mobile app."""
|
||||||
user_agent = request.META.get('HTTP_USER_AGENT', 'No User-Agent')
|
user_agent = request.META.get('HTTP_USER_AGENT', 'No User-Agent')
|
||||||
|
|
||||||
return JsonResponse({
|
# Simple HTML response that's easy to see in iframe
|
||||||
'user_agent': user_agent,
|
html = f"""
|
||||||
'is_mobile_app_detected': (
|
<!DOCTYPE html>
|
||||||
'CapacitorHttp' in user_agent or
|
<html>
|
||||||
'com.firebugit.keepitgoing' in user_agent or
|
<head>
|
||||||
('KeepItGoing' in user_agent and 'Mobile' in user_agent)
|
<title>Debug Info</title>
|
||||||
),
|
<style>
|
||||||
'headers': dict(request.META),
|
body {{ font-family: monospace; padding: 20px; }}
|
||||||
})
|
.detected {{ color: green; font-weight: bold; }}
|
||||||
|
.not-detected {{ color: red; font-weight: bold; }}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Mobile App Debug Info</h2>
|
||||||
|
<p><strong>User-Agent:</strong><br>{user_agent}</p>
|
||||||
|
<p><strong>Contains 'wv':</strong> {'wv' in user_agent.lower()}</p>
|
||||||
|
<p><strong>Contains 'CapacitorHttp':</strong> {'CapacitorHttp' in user_agent}</p>
|
||||||
|
<p><strong>Is Mobile App Detected:</strong>
|
||||||
|
<span class="{'detected' if ('wv' in user_agent.lower() or 'CapacitorHttp' in user_agent) else 'not-detected'}">
|
||||||
|
{('wv' in user_agent.lower() or 'CapacitorHttp' in user_agent)}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return HttpResponse(html)
|
||||||
|
|||||||
Reference in New Issue
Block a user