Internal
Public Access
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""Debug views for troubleshooting mobile app."""
|
|
|
|
from django.http import JsonResponse, HttpResponse
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.http import require_http_methods
|
|
|
|
|
|
@csrf_exempt
|
|
@require_http_methods(["GET", "POST"])
|
|
def debug_user_agent(request):
|
|
"""Return the User-Agent header for debugging mobile app."""
|
|
user_agent = request.META.get('HTTP_USER_AGENT', 'No User-Agent')
|
|
|
|
# Simple HTML response that's easy to see in iframe
|
|
html = f"""
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Debug Info</title>
|
|
<style>
|
|
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)
|