From d32cef9661f6df3361d3e41222800c50fbd42571 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Tue, 28 Jun 2022 13:51:11 +0300 Subject: [PATCH] [~] Refactor --- d1/f2.py | 12 ++++++++---- d1/wsgi/.htaccess | 9 ++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/d1/f2.py b/d1/f2.py index 00e4722..7080da1 100644 --- a/d1/f2.py +++ b/d1/f2.py @@ -14,6 +14,12 @@ sys.path.insert(0, os.path.dirname(__file__)) def application(environ, start_response): + def op1(data=None): + if data is None: + data = traceback.format_exc() + with io.open('log.txt', 'a') as f: + f.write(data) + try: t4 = int(environ.get('CONTENT_LENGTH', '0')) t3 = environ['wsgi.input'].read(t4) @@ -79,8 +85,7 @@ def application(environ, start_response): '-v', '-q', ] - with io.open('1.json', 'w') as f: - f.write(json.dumps(dict(t17=t17, t3=t3.decode('utf-8')))) + with subprocess.Popen( t17, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE ) as p: @@ -128,7 +133,6 @@ def application(environ, start_response): t1 = start_response(t15, t16) t1(t10) except: - with io.open('log.txt', 'a') as f: - f.write(traceback.format_exc()) + op1() return [] diff --git a/d1/wsgi/.htaccess b/d1/wsgi/.htaccess index 0c85dbe..33e93ba 100644 --- a/d1/wsgi/.htaccess +++ b/d1/wsgi/.htaccess @@ -1,4 +1,11 @@ -# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN + +RewriteEngine On +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d + + PassengerAppRoot "/home/productg/p1/p1" PassengerBaseURI "/" PassengerPython "/home/productg/p1/tmp/env3/bin/python"