GithubHelp home page GithubHelp logo

file-parser's Introduction

File-parser

File-parser is a simple service that accepts a text file and returns an overall word count and a break-down of counts for each individual word in the file.

Description

The file-parser service can be used either through a web interface or programmatically. The supported actions are 'GET' and 'POST'.

The service determines the format of the response based on the headers in the request. In response to a GET request with headers that indicate HTML support, the service will return an HTML formatted webpage with a file upload form. A POST request to the service with HTML headers (and a file to parse) will return the parsed file data as HTML.

If http headers support JSON, a GET request will return a JSON response:

      { "status":"success",
        "service":"file upload and parse"
      }

POSTing a file to the service with JSON headers will return the parsing data in JSON format:

      { "status":"success",
        "data": {
          "parsed_file": <filename>,
          "total_word_count": <total word count>,
          "word_occurrences": [ 
            {     "word":<word>,
                  "count":<word count>
            },
            ...
           ]
          }
      }

Dependancies

File-parser is built on the Play Framework from Typesafe. In order to run, JDK 6 or later is required.

Play version 2.3.7 also requires sbt version 0.13.5 or later.

Setup

To run the application locally:

  • install JDK 6 or later
  • (optional) install sbt 0.13.5 or later
  • clone this repository
  • if sbt is installed: in a console window, from the root directory of the repository type sbt run
  • if sbt is not installed: the application can be run by typing ./activator run from the root directory

Usage

To interact with the service via web interface, access http://localhost:9000/ in a web browser.

To interact with the service via cURL:

Make a GET request via curl with JSON headers:

curl -X GET --header "Accept: application/json" http://localhost:9000/

POST a file to be parsed via curl with JSON headers:

curl -X POST -F [email protected] --header "Accept: application/json" http://localhost:9000/

Credits

  • Format of JSON responses based on JSend
  • Code to translate Play AnyContentAsMultipartFormData to Array[Bytes] for the upload tests from G-Node/GCA-Web

file-parser's People

Contributors

atrout avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.