Эх сурвалжийг харах

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

Radoslav Petrov 7 жил өмнө
parent
commit
ed0804d716

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

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