Code Monkey home page Code Monkey logo

polyglot's Introduction

polyglot

Code for my Becoming a Polyglot talk

In this repository are examples in several languages of a basic API in a common framework for that language. They all use the same mongodb backend, and all use the same single page HTML application.

All of them run at http://localhost:3000

The following paths work in each environment:

  • /api/quotes => quote list
  • /api/quotes/random => random quote
  • / => hello world from the framework
  • /demo => Single page HTML application

Setup

You will need to have mongodb installed and running. Installation info for the major platforms is at https://docs.mongodb.org/manual/installation/

To insert the information from the quoteid.json file to get your DB started, use the following command:

mongoimport --collection quotes --file ../data/quoteid.json --type json --jsonArray

# PHP
$ php composer.phar install 

$ pecl install mongo
$ php -i | grep ini - add extension=mongo.so to this file, or create it
$ php -S 0.0.0.0:3000 -t ./public/ ./public/index.php

Python

cd python; python setup.py install; python flask-server.py

Node

cd node; npm install; node express-server.js cd node; npm install; node hapi-server.js

Ruby

cd ruby; gem install bundler; bundle install; ruby sinatra-server.rb

Perl

sudo cpan -i -f Dancer Dancer::Plugin::CRUD JSON MongoDB; perl dancer-server.pl

Docker setup

You can skip all of the setup instructions below and use the docker container if you like. First, install docker from http://www.docker.com/toolkit Next:

  • Start the docker shortcut utility, note the IP address it gives
  • docker run -i -t -p 80:3000 synedra/polyglot /bin/bash
  • /etc/init.d/mongodb start
  • cd ../data
  • mongoimport --collection quotes --file ../data/quoteid.json --type json --jsonArray
  • run the startup command for whichever language you like
  • The server will be running on http://{docker-ip}

polyglot's People

Contributors

synedra avatar dshafik avatar

Watchers

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