Use more robust http server and fix cloudproxy ghost session
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2020-12-30 21:18:15 +01:00
parent ccd01664e6
commit 26900df6fa
4 changed files with 14 additions and 4 deletions

View File

@ -1,8 +1,9 @@
import logging
from functools import wraps
from operator import attrgetter, itemgetter
from flask import redirect, render_template, request, url_for, abort
from werkzeug.serving import WSGIRequestHandler
from gevent.pywsgi import WSGIServer
from . import utils
from .config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG
@ -187,5 +188,6 @@ def admin_edit(link_id=None):
def run():
WSGIRequestHandler.protocol_version = 'HTTP/1.1'
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
logging.basicConfig(level=logging.DEBUG if IS_DEBUG else logging.INFO)
http_server = WSGIServer(('', APP_PORT), app)
http_server.serve_forever()

View File

@ -19,6 +19,7 @@ MYSQL_ENABLED = False
app = Flask(__name__)
app.name = 'PyNyaaTa'
app.debug = IS_DEBUG
app.secret_key = urandom(24).hex()
app.url_map.strict_slashes = False
auth = HTTPBasicAuth()

View File

@ -122,6 +122,13 @@ def curl_content(url, params=None, ajax=False, debug=True):
if 'solution' in response:
output = response['solution']['response']
if http_code == 500:
json_response = requests.post(CLOUDPROXY_ENDPOINT, headers=headers, data=dumps({
'cmd': 'sessions.destroy',
'session': cloudproxy_session,
}))
cloudproxy_session = None
if debug and http_code != 200:
getLogger().exception('%s\n\n%s' % (str(e), json_response.text))
except (RequestException, CaptchaException) as e:

View File

@ -11,4 +11,4 @@ cloudscraper==1.2.50
Js2Py==0.70
polling2==0.4.6
dateparser==1.0.0
Werkzeug==1.0.1
gevent==20.12.1