python3 compatibility + webapp to flask refactoring

This commit is contained in:
Kaan Soral
2024-01-27 20:37:44 +03:00
parent 5180a9c31c
commit 53b3de28ab
81 changed files with 11213 additions and 1085 deletions
+32 -27
View File
@@ -1,31 +1,36 @@
from config import *
from functions import *
class MainHandler(webapp.RequestHandler):
@ndb.toplevel
def get(self,name):
domain=gdi(self)
if name=="hash":
start=datetime.now()
logging.info(pbkdf2_hex("test","123456",iterations=160))
logging.info(mssince(start))
elif name=="levels":
xp=200
for i in xrange(100):
new_xp=xp
while new_xp>=100: new_xp/=10
new_xp=int(new_xp)
while new_xp*10<=xp: new_xp*=10
xp=new_xp
self.response.out.write("level %s %sxp %s worms %s 40K's<br />"%((i+1),xp,xp/200.0,xp/40000.0))
xp*=1.25
elif name.startswith("pixi_"):
whtml(self,"utility/htmls/tests/%s.html"%name,domain=domain)
else:
self.response.out.write("test")
def post(self,name):
self.get(name)
def test():
@after_this_request
def add_header(response):
response.headers['X-Foo'] = 'Parachute'
return response
application = webapp.WSGIApplication([
('/test/?(.*)', MainHandler)
],debug=is_sdk)
@app.route('/test', methods=['POST', 'GET'])
@app.route('/test/<name>', methods=['POST', 'GET'])
@ndb.toplevel
def serve_test(name=""):
domain=gdi(request)
if name=="hash":
start=datetime.now()
logging.info(pbkdf2_hex("test","123456",iterations=160))
logging.info(mssince(start))
elif name=="levels":
xp=200
for i in xrange(100):
html=""
new_xp=xp
while new_xp>=100: new_xp/=10
new_xp=int(new_xp)
while new_xp*10<=xp: new_xp*=10
xp=new_xp
html+="level %s %sxp %s worms %s 40K's<br />"%((i+1),xp,xp/200.0,xp/40000.0)
xp*=1.25
return html
elif name.startswith("pixi_"):
return shtml("utility/htmls/tests/%s.html"%name,domain=domain)
else:
request.response=make_response('Setting the cookie')
#test()
return request.response