Instead of using auto-generated text, why not use something more interesting? This project takes the top books off Project Gutenberg and makes them available to you in small (random, thought provoking) pieces. Make sure you check out the website.
Because the world is nothing but APIs all the way down, make sure you check out the Lipsumo API. Then, integrate all this amazing (mind blowing, world changing) functionality into your own projects!
There's only one endpoint for the API and the response contains everything you need:
curl http://lipsumo.hound.io/paragraphs
{
"Author": "Frederick Douglass",
"Title": "The Narrative of the Life of Frederick Douglass",
"Id": 23,
"Data": [
"paragraph1",
"paragraph2",
"paragraph3",
"paragraph4"
]
}
If you'd like to get a different number of paragraphs outside the default of four, it is a query parameter:
curl http://lipsumo.hound.io/paragraphs?num=2
For a live example, take a look at the website. It uses the standard API every time a different number of paragraphs are selected.
For anyone interested in using this project themselves or doing some development, it is pretty easy to get setup and running locally.
- Follow the instructions to install GAE GO SDK
- Setup the local app config
cp gae/app.yaml.example gae/app.yaml
cp gae/config.json.example gae/config.json
- Fetch the dependencies
goapp get github.com/ant0ine/go-json-rest
- Serve away!
goapp serve gae
The books are all compiled into json files that get checked in (and deployed). You can either add new books or change the structure of the existing ones by modifying convert.py
.
- Download the text version of the book you're interested in from Project Gutenberg
- Save the downloaded book into
./raw_books/
and name it likepg100.txt
where 100 is the ID of the book. - Run
convert.py
App Engine makes it easy for anyone to run their own version of Lipsumo. Follow the instructions and upload via. goapp deploy gae
. You'll have your own version running and will be able to do whatever you'd like with it.