GithubHelp home page GithubHelp logo

keithpjolley / randomcountry Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 602 KB

alexa node code to return the name of a random country (or really any item on a list)

License: MIT License

JavaScript 73.80% HTML 9.53% CSS 13.34% Shell 3.34%

randomcountry's Introduction

Random Country

Based on Alexa Weather Forecaster, as demo to show how to create an Amazon Alexa (Echo) Skill.

what

This project is a node service that returns, through html/http/alexa, the name of a random country from a static list of countries originally from https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags. The first iteration did a pull from http://country.io/data/ but I liked having the flags and the simplicity of a static list. The downside is that pulling the data from the other site was cool and put the burden of keeping the data up to date on someone else. I don't assume that this list is authoritative or the best, but they do have a flag. :)

how

Install node.
Install npm.

% git clone
% cd randomcountry
% npm install
% npm start
% test/test2.sh
% echo "The following should all look 'reasonable'."
% for i in index.html index.json alexa help.html
do
  echo ">>> $i ----------------------------------------"
  curl "http://localhost:8889/${i}"
done

why

An interesting side note (to me). The genesis of this project is that I was noodling on how to migrate an existing project to javascript. I was screenscraping using python/beautifulsoup and wished that there was an API for the data I needed. I was also working on getting an object from an object of objects when my daughter walked in and said "Dad! What's the name of a random country?! Hurry!!".

I got the first version online, using express, when I saw that Amazon was giving away hoodies for new Alexa skills. We have an Alexa so this seemed like a perfect opportunity.

I originally made a generic node express web page with html and json output, then extended it to serve Alexa, however, no security meant it couldn't pass Amazon's certification process. When I added security the code became so ugly I rewrote from the Weather Forecaster base code. It seems verifying the POST is coming from Alexa could be optional - no state secrets in this particular skill.

keith

© 2017 -- Jamul Heavy Industries, LLC
Jamul, CA
MIT License

randomcountry's People

Contributors

keithpjolley avatar

Watchers

James Cloos 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.