Преглед на файлове

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

Radoslav Petrov преди 7 години
родител
ревизия
ed0804d716
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  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)