Browse Source

[python] bump robyn to version 0.37.0 (#8357)

Sanskar Jethi 2 years ago
parent
commit
17b7ef209d

+ 15 - 12
frameworks/Python/robyn/app-const.py

@@ -2,24 +2,27 @@ import multiprocessing
 import os
 import os
 
 
 from robyn import Robyn
 from robyn import Robyn
+from robyn.argument_parser import Config
 
 
-app = Robyn(__file__)
 
 
+class SpecialConfig(Config):
+    def __init__(self):
+        super().__init__()
+        self.workers = 2
+        self.processes = (os.cpu_count() * 2) + 1
+        self.log_level = "WARN"
 
 
[email protected]('/plaintext', const=True)
-def plaintext() -> str:
-    return "Hello, world!"
+
+app = Robyn(__file__, config=SpecialConfig())
 
 
 
 
-if __name__ == '__main__':
-    _is_travis = os.environ.get('TRAVIS') == 'true'
[email protected]("/plaintext", const=True)
+def plaintext() -> str:
+    return "Hello, world!"
 
 
-    workers = multiprocessing.cpu_count() * 2 + 1
-    if _is_travis:
-        workers = 2
 
 
-    app.processes = workers
-    app.add_header("Server", "Robyn")
-    app.add_header("Content-Type", "text/plain")
+if __name__ == "__main__":
+    app.add_response_header("Server", "Robyn")
+    app.add_response_header("Content-Type", "text/plain")
 
 
     app.start(url="0.0.0.0", port=8080)
     app.start(url="0.0.0.0", port=8080)

+ 15 - 12
frameworks/Python/robyn/app.py

@@ -2,24 +2,27 @@ import multiprocessing
 import os
 import os
 
 
 from robyn import Robyn
 from robyn import Robyn
+from robyn.argument_parser import Config
 
 
-app = Robyn(__file__)
 
 
+class SpecialConfig(Config):
+    def __init__(self):
+        super().__init__()
+        self.workers = 2
+        self.processes = (os.cpu_count() * 2) + 1
+        self.log_level = "WARN"
 
 
[email protected]('/plaintext')
-def plaintext() -> str:
-    return "Hello, world!"
+
+app = Robyn(__file__, config=SpecialConfig())
 
 
 
 
-if __name__ == '__main__':
-    _is_travis = os.environ.get('TRAVIS') == 'true'
[email protected]("/plaintext")
+def plaintext() -> str:
+    return "Hello, world!"
 
 
-    workers = multiprocessing.cpu_count() * 2 + 1
-    if _is_travis:
-        workers = 2
 
 
-    app.processes = workers
-    app.add_header("Server", "Robyn")
-    app.add_header("Content-Type", "text/plain")
+if __name__ == "__main__":
+    app.add_response_header("Server", "Robyn")
+    app.add_response_header("Content-Type", "text/plain")
 
 
     app.start(url="0.0.0.0", port=8080)
     app.start(url="0.0.0.0", port=8080)

+ 2 - 1
frameworks/Python/robyn/requirements-const.txt

@@ -1 +1,2 @@
-robyn==0.19.1
+uvloop==0.17.0
+robyn==0.37.0

+ 2 - 1
frameworks/Python/robyn/requirements.txt

@@ -1 +1,2 @@
-robyn==0.14.0
+uvloop==0.17.0
+robyn==0.37.0

+ 2 - 2
frameworks/Python/robyn/robyn-const.dockerfile

@@ -1,4 +1,4 @@
-FROM python:3.9
+FROM python:3.11
 
 
 ADD ./ /robyn
 ADD ./ /robyn
 
 
@@ -8,4 +8,4 @@ RUN pip3 install -r /robyn/requirements-const.txt
 
 
 EXPOSE 8080
 EXPOSE 8080
 
 
-CMD ["python", "app-const.py"]
+CMD ["python", "app-const.py", "--log-level", "warn"]]

+ 1 - 1
frameworks/Python/robyn/robyn.dockerfile

@@ -8,4 +8,4 @@ RUN pip3 install -r /robyn/requirements.txt
 
 
 EXPOSE 8080
 EXPOSE 8080
 
 
-CMD ["python", "app.py"]
+CMD ["python", "app.py", "--log-level", "warn"]