Is there a way to check if a folder exists on a web server with Python? (something like “os.path.isdir” but reading HTTP responses as “HTTP/404” if not found)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can check if a server is serving a file by requesting it in urllib and seeing if it was successfull with a 200 error or unsuccessful.
I think it’s difficult to see what is a directory and what isn’t. What is a directory though? With modern web frameworks people can route urls however they want. Are you defining a a directory as anything that has a webpage underneath of it even though it might not be hierarchical order on the filesystem?