0

I'm sorry in advance for the rookie question. I'm learning Flask and I have a Python file that I'm now using in a Flask app. When I run the app.py file in Python (python app.py), everything works. However, when I run it in Flask, I get the error: AttributeError: 'Flask' object has no attribute 'tagger'.

The resTag function is trying to return a response from the Tagger -> tag function. The result is the error message, mentioned above.

Any advice?

app.py

app = Flask(__name__)

@app.route('/')
def resTag():
    text = request.values['text']
    tokenized = request.values.get('tokenized') in ('1', 'True', 'true')
    return app.tagger.tag(text, tokenized)


class Tagger(object):
    def __init__(self, model, tokenizer, labels, config):
        self.model = model
        self.tokenizer = tokenizer
        self.labels = labels
        self.config = config
        self.session = None
        self.graph = None

    def tag(self, text, tokenized=False):
        # Stuff to do
0

1 Answer 1

1

return statement should be return Tagger.tag(text, tokenized)

Sign up to request clarification or add additional context in comments.

1 Comment

You're an angel. It works! Thank you! I've learned from this. I'll mark it soon! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.