https://github.com/craigfe/scala-question-generator
A Scala REST API for generating simple maths questions.
https://github.com/craigfe/scala-question-generator
play-framework rest-api scala
Last synced: over 1 year ago
JSON representation
A Scala REST API for generating simple maths questions.
- Host: GitHub
- URL: https://github.com/craigfe/scala-question-generator
- Owner: craigfe
- License: gpl-3.0
- Created: 2017-12-19T13:17:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-22T13:15:54.000Z (over 8 years ago)
- Last Synced: 2025-02-11T19:39:33.842Z (over 1 year ago)
- Topics: play-framework, rest-api, scala
- Language: Scala
- Homepage:
- Size: 509 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Question Generator REST API
This project is a simple REST API written in Scala using the [Play framework](https://playframework.com/).
The API provides a single URI (```/question```), which generates a simple addition question and returns a JSON response such as the following:
```
{
"question" : "94 + 980?",
"answers" : [ 1044, 1074, 1071, 1054 ]
}
```
The URI accepts two optional query parameters, ``lower`` and ``upper``, which specify the lower and upper bounds of the answer
(inclusive). The lower and upper bounds default to the minimum and maximum values: [0, 1,000,000]. Invalid query
parameters will result in an Error 400 response.
The operation of the API is simple: The ``/question`` URI is managed by the [QuestionController](app/controllers/QuestionController.scala)
class, which invokes a singleton instance of the [QuestionGenerator](app/services/QuestionGenerator.scala) class in
order to generate questions. These two files have been commented excessively in order to explain the design goals of the code as well as the functionality.
## Usage
This project can be executed using [sbt](http://www.scala-sbt.org/) as follows:
```
sbt run
```
This will initialise a development server at http://localhost:9000 to host the application. Further information is contained on the homepage.