Use more robust http server and fix cloudproxy ghost session
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ccd01664e6
commit
26900df6fa
@ -1,8 +1,9 @@
|
|||||||
|
import logging
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from operator import attrgetter, itemgetter
|
from operator import attrgetter, itemgetter
|
||||||
|
|
||||||
from flask import redirect, render_template, request, url_for, abort
|
from flask import redirect, render_template, request, url_for, abort
|
||||||
from werkzeug.serving import WSGIRequestHandler
|
from gevent.pywsgi import WSGIServer
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG
|
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():
|
def run():
|
||||||
WSGIRequestHandler.protocol_version = 'HTTP/1.1'
|
logging.basicConfig(level=logging.DEBUG if IS_DEBUG else logging.INFO)
|
||||||
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
|
http_server = WSGIServer(('', APP_PORT), app)
|
||||||
|
http_server.serve_forever()
|
||||||
|
@ -19,6 +19,7 @@ MYSQL_ENABLED = False
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.name = 'PyNyaaTa'
|
app.name = 'PyNyaaTa'
|
||||||
|
app.debug = IS_DEBUG
|
||||||
app.secret_key = urandom(24).hex()
|
app.secret_key = urandom(24).hex()
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
auth = HTTPBasicAuth()
|
auth = HTTPBasicAuth()
|
||||||
|
@ -122,6 +122,13 @@ def curl_content(url, params=None, ajax=False, debug=True):
|
|||||||
if 'solution' in response:
|
if 'solution' in response:
|
||||||
output = response['solution']['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:
|
if debug and http_code != 200:
|
||||||
getLogger().exception('%s\n\n%s' % (str(e), json_response.text))
|
getLogger().exception('%s\n\n%s' % (str(e), json_response.text))
|
||||||
except (RequestException, CaptchaException) as e:
|
except (RequestException, CaptchaException) as e:
|
||||||
|
@ -11,4 +11,4 @@ cloudscraper==1.2.50
|
|||||||
Js2Py==0.70
|
Js2Py==0.70
|
||||||
polling2==0.4.6
|
polling2==0.4.6
|
||||||
dateparser==1.0.0
|
dateparser==1.0.0
|
||||||
Werkzeug==1.0.1
|
gevent==20.12.1
|
||||||
|
Reference in New Issue
Block a user