July 2018
Intermediate to advanced
324 pages
8h 14m
English
The API implementation will be straightforward. As per our requirements, we are going to accept only one parameter for uploading the file. Hence, this API will accept only an HTTP POST request method. The following is a code snippet of the /doc-parser API:
import falconfrom falcon_multipart.middleware import MultipartMiddlewarefrom parser import doc_to_textclass DocParserResource: def on_post(self, req, resp): """Handles POST requests""" try: file_object = req.get_param('file') # file validation if file_object.type != 'application/msword' or file_object.filename.split('.')[-1] != 'doc': raise ValueError('Please provide a valid MS Office 93 -2003 document file.') # calling _doc_to_text method from parser.py ...Read now
Unlock full access