This should be a simple question, but I haven\'t been able to find a way to make it work.
Essentially, I have a silly localhost page that I use in my webdevelopment.
Check out this PHP solution: Calculating Color Contrast with PHP by Andreas Gohr. It can be ported to any language of course.
He also has a very nice demonstration of his contrast analyzer where you can find some minimal contrast levels to work with.