ploughshares/check_accessibility.py

51 lines
1.9 KiB
Python

#!/usr/bin/env python3
import requests
import json
import sys
from urllib.parse import quote
def check_contrast(url):
"""
Check contrast issues using the WAVE API
"""
try:
# Make a request to the local server
response = requests.get(url)
content = response.text
# Print basic page info
print(f"Checking accessibility for: {url}")
print("Page loaded successfully.")
# Basic contrast check - look for color definitions in CSS
css_colors = []
if "style" in content:
print("\nDetected inline styles. Potential contrast issues should be reviewed.")
if "background-color" in content and "color" in content:
print("Detected color and background-color properties. Check for proper contrast.")
# Manual check instructions
print("\n=== MANUAL ACCESSIBILITY CHECKS ===")
print("1. Check text contrast with background (should be at least 4.5:1 for normal text)")
print("2. Check button contrast with text (should be at least 3:1)")
print("3. Check form field contrast with labels")
print("4. Ensure links are distinguishable from regular text")
print("5. Check hover/focus states for interactive elements")
print("\nTo perform a full accessibility audit, please use one of these tools:")
print("- Chrome DevTools Lighthouse: Open DevTools > Lighthouse > Accessibility")
print("- WAVE Browser Extension: https://wave.webaim.org/extension/")
print("- axe DevTools: https://www.deque.com/axe/devtools/")
return True
except Exception as e:
print(f"Error checking accessibility: {e}")
return False
if __name__ == "__main__":
url = "http://localhost:5005"
if len(sys.argv) > 1:
url = sys.argv[1]
check_contrast(url)