Sfoglia il codice sorgente

Allocate on each request the variable representing the JSON data (#3193)

Radoslav Petrov 7 anni fa
parent
commit
ed0804d716
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 3 2
      frameworks/Python/tornado/commons.py

+ 3 - 2
frameworks/Python/tornado/commons.py

@@ -17,6 +17,7 @@ class PlainHandler(BaseHandler):
         self.set_header("Content-Type", "text/plain")
 
 class HtmlHandler(BaseHandler):
+
     def set_default_headers(self):
         self.set_header("Content-Type", "text/html; charset=UTF-8")
 
@@ -34,8 +35,8 @@ class PlaintextHelloWorldHandler(PlainHandler):
 
 
 class JsonHelloWorldHandler(JsonHandler):
-    HELLO_WORLD = {"message": "Hello, World!"}
 
     def get(self):
-        obj = json.dumps(self.HELLO_WORLD)
+        HELLO_WORLD = {"message": "Hello, World!"}
+        obj = json.dumps(HELLO_WORLD)
         self.finish(obj)