[Tutor] Flask-Python Beginner

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 26 04:14:00 EDT 2020


On 26/10/2020 00:26, Baptista Albert wrote:
> Hi,
> 
> I doing a small project by myself on building a resume parser. I wrote the
> Python script and it works just fine with the document path hardcoded in it.
> 
> I am not trying to convert into an API using flask and am facing a lot o> issues,

I've used Flask a couple of times and it should be good for your
purpose. But in common with other frameworks you need to bend
your code to its rules.

> app = Flask(__name__)
> api= Api(app)
> #@app.route('/resumeparser2', methods=['GET'])
> 
> #extracting data from docx
> 
> class resparse:
> 
>     def resumeparser2(self) :
          <snip body>
> 
> 
> api.add_resource(resparse,'/resumeparser2')
> 

> Errors:
> 
> PS C:\Users\Ajay Charles\Downloads\Python\PythonProjects> &
> C:/Python38/python.exe "c:/Users/Ajay
> Charles/Downloads/Python/PythonProjects/resumeparser2.py"
> Traceback (most recent call last):
>   File "c:/Users/Ajay
> Charles/Downloads/Python/PythonProjects/resumeparser2.py", line 58, in
> <module>
>     api.add_resource(resparse,'/resumeparser2')
<snip>

> AttributeError: type object 'resparse' has no attribute 'as_view'

The error is quite correctly telling you that your resparse object
does not have an attribute as_view. in fact resparse is a class,
I suspect it should be an instance? And it should either be a
descendant of some flask class or it should provide an interface
that includes the methods that Flask will call, in this
case as_view() as a minimum. (It may be that you are missing a
decorator somewhere, as I recall flask uses a lot of decorators
to add its own methods to things)

But you'll need to check the Flask docs to find out.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list