0

首先,我使用烧瓶。

其次,我yield喜欢下面的代码。

def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        def generate():
            yield '<pre>'
            yield "Processing...\n"
            file = CheckFile(f.filename, f.read())
            file.parse()
            for note in file.validate():
                if note.oddity_type == Note.ERROR:
                    yield '<span style="color: red;">%s</span>' % str(note)
                if note.type == Note.WARNING:
                    yield '<span style="color: orange;">%s</span>' % str(note)
                if note.type == Note.INFO:
                    yield '<span style="color: blue;">%s</span>' % str(note)
                if note.type == Note.FATAL:
                    yield '<span style="color: red;">%s</span>' % str(note)
            yield '</pre>'
        return Response(stream_with_context(generate()))
    if request.method == 'GET':
        return app.send_static_file('index.html')

所以在__init__ inCheckFile之后is completed, I返回values withyield` 到响应。

我想做的是能够yield在.__init__file.parse()

4

0 回答 0