فهرست منبع

Display an 'It Works' message when the root URL is requested with the GET method

Fabien LOISON 14 سال پیش
والد
کامیت
9179e5562a
1فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 12 0
      radicale/__init__.py

+ 12 - 0
radicale/__init__.py

@@ -161,6 +161,18 @@ class Application(object):
         environ["PATH_INFO"] = self.sanitize_uri(environ["PATH_INFO"])
         log.LOGGER.debug("Sanitized path: %s", environ["PATH_INFO"])
 
+        # Display an "It Works" message if the root URL is requested with
+        # the GET method
+        if environ["REQUEST_METHOD"].lower() == "get" \
+        and environ["PATH_INFO"] == "/":
+            headers = {"Content-type": "text/html"}
+            start_response("200 OK", list(headers.items()))
+            return ["<html>\n",
+                    "<head><title>Radicale Works!</title></head>\n",
+                    "<body><h1>Radicale Works!</h1>",
+                    '<a href="http://radicale.org/">radicale.org</a></body>',
+                    "\n</html>"]
+
         # Get content
         content_length = int(environ.get("CONTENT_LENGTH") or 0)
         if content_length: