So I've been using Google App Engine Webapp2 for years. Now Python 2 is deprecated and Webapp2 only works for Python 2. All my classes use are designed to be interpreted by webapp2. Instead of trying to change tens of thousands lines of code by changing all the classes for the pages to Flask I'm working on a simple fix. I just need when the class says self.response.write("whatever your writing") to compile all of that and return it to work with flask. The problem I'm running into is adding .write() I can do just self.response("whatever add") but I can't figure out how to make self.response.write("whatever") work. Any advice on how to add .write() and make it work would be greatly appreciated. Heres what I've done so far and this code works great but I still need to add .write().
from flask import Flask
from flask import request
app = Flask(__name__)
class BaseHandler():
def __init__(self):
self.data = ""
def response(self,stuffAdd):
self.data+=stuffAdd
class MainPage(BaseHandler):
def get(self):
self.response("first thing to add")
self.response("second thing to add")
@app.route('/',methods=['GET'])
def hello_world():
if request.method == 'GET':
newMain=MainPage()
newMain.get()
return newMain.data