roman_numerals_webservice package

Submodules

roman_numerals_webservice.cli module

Console script for roman_numerals_webservice.

roman_numerals_webservice.roman_numerals_webservice module

Main module.

class roman_numerals_webservice.roman_numerals_webservice.RomanNumeralsWebservice[source]

Bases: object

arabic_to_roman()[source]

Implements endpoint for Arabic to Roman web-service

This method expects json request with a json payload of the following form:

'{"roman": <input_str>}'

Where <input_str> is the input Arabic numerals as integer.

With curl, one can use this endpoint in the following way:

$ curl -d '{"arabic" : 1987}' -H "Content-Type: application/json" -X POST http://localhost:8080/arabic_to_roman

The output will be:

"{"roman": "MCMLXXXVII"}"
Returns:
json string of the form '{"roman": <res_str>}' where
<res_str> is an str which represents the
input Arabic numeral converted to a Roman Numeral.
Return type:str
Raises:cherrypy.HTTPError – If the input is not a in the range [1,...399], if the json payload is ill-formed, a cherrypy.HTTPError(status=400) is raised. This error will translate to a BAD_REQUEST HTML status code.
roman_to_arabic()[source]

Implements endpoint for Roman to Arabic web-service

This method expects json request with a json payload of the following form:

'{"roman": <input_str>}'

Where <input_str> is the input Roman numerals as string. The string can be in CAPTIAL lower or mIxeD case.

With curl, one can use this endpoint in the following way:

$ curl -d '{"roman" : "XL"}' -H "Content-Type: application/json" -X POST http://localhost:8080/roman_to_arabic

The output will be:

{"arabic": 40}"
Returns:
json string of the form '{"arabic": <res_int>}' where
<res_int> is an integer which represents the
input Roman numeral converted to an Arabic Numeral.
Return type:str
Raises:cherrypy.HTTPError – If the input it not a valid Roman numeral or if the json payload is ill-formed, a cherrypy.HTTPError(status=400) is raised. This error will translate to a BAD_REQUEST HTML status code.

Module contents

Top-level package for roman_numerals_webservice.