Endpoint: https://gy2aa8c57c.execute-api.us-east-1.amazonaws.com/dev
Parameters:
-
text
-str
- Required -
node_colors
-array
- An array of 2 hex codes, like['#FFF', '#CCC']
. These codes are used for the start and end node colors, respectively. -
color
-str
- A hex code,, like'#FFF'
. This is the color of the path -
split
-object
- An object like so:
{
"words": ["quality", "knowledge", "logic"],
"color": "#000"
}
First, take care of the requirements:
-
pip install -r requirements.txt
-
brew install caskformula/caskformula/inkscape
-
npm install -g serverless
-
sls plugin install -n serverless-python-requirements
-
Requires Docker (serverless-python-requirements uses Docker to build)
sls deploy
sls logs -f app --tail
sls deploy && sls logs -f app --tail
- POST Request to the endpoint
POST /dev HTTP/1.1
Host: gy2aa8c57c.execute-api.us-east-1.amazonaws.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 87c7679b-0719-608d-016a-f10e6f00b276
{
"text" : "I guess various sentences may lead to various structures.
A short one. Then a quick twist and run, further than we'd anticipated.
I guess. Well, I know that one thing is for certain - long,
run on sentences have a place here. But! So do quick ones. Tight little turns.
Another tactic would be to send out a long, long sentence, broken up by not
much else other than the occasional - well, yes, that - out of nowhere, how surprising.
The more sentences, the merrier. Try giving me a whole book :)",
"node_colors":["FF101A", "#CCC"],
"colors": ["#FF59E7"]
}
-
The
text
is converted into an XML Path. -
The XML Path is converted into a full SVG file using
svgpathtools
. -
The contents of the file are checksummed using
sha1
and named[file-checksum].svg
-
The file is uploaded to S3. There is a check to ensure we do not upload duplicate files - hence the checksumming.
-
The file's URL is returned as a JSON response like so:
{ 'statusCode': 200, 'body': {"s3_url": "https://s3.amazonaws.com/word-art-svgs/f3f5ea8d8cd19705f3d743c8897eddf0c0e3840a.svg"}