Coder Social home page Coder Social logo

simple-app's Introduction

Big Rob Coffee Flask Application

Big Rob

Introduction

Over the last year or so I have testing and running demos on a number of platforms and environments. While a basic 'Hello Word' app would do its a little bit boring. As a result I have created a number of examples that I can use to learn or highlight the capabilities of these environments.

The idea ia that the appication can be deployed standalone to show how thinsg are packaged up and configured for use on the differnet platforms, it can also use used to show interaction with other compoenets like Redis or MySQL etc.

The thoughts that I had around deployments where using traditional server/virtual machine deployments and also container based making use of microservices. The platforms that I had in mind;

  • Pivotal Cloud Foundry (PCF)
  • Pivotal Web Services
  • OSS Cloud Foundry
  • Cisco Shipped
  • Cisco Mantl
  • Cisco Cloud Center
  • Cisco Metacloud
  • Docker
  • Traditional Application
  • Mircoservice Application

What is the app

When the application is running you will be presented with a simple web page with the option to vote for you favourite coffee bean (the vote function doesnt work yet!). It will also provide information about what container/host the page is being serverd by, this is useful when scaling the application out.

Vote app

Configuration

The directory structure is;

.
├── Dockerfile
├── Procfile
├── README.md
├── app.py
├── requirements.txt
├── static
│   ├── images
│   │   ├── bigrob.png
│   │   ├── el-salvador.jpg
│   │   ├── ethiopia.jpg
│   │   └── rwanda.jpg
│   ├── js
│   │   ├── freelancer.js
│   │   └── freelancer.min.js
│   └── stylesheets
│       ├── bootstrap.min.css
│       ├── cover.css
│       ├── font-awesome.min.css
│       ├── freelancer.css
│       ├── freelancer.min.css
│       └── style.css
└── templates
    └── index.html

The static/ directory contains the images, javascript and CSS files used by the application. The templates/ directory contains the basis for the HTML page.

The app.py is the main code for the applicaton.

Getting started

Cloud Foundry

To run on Cloud Foundry, I tested on PWS

git clone https://github.com/clijockey/vote-app-flask.git
cd vote-ap-flask
cf push br-coffee

You obviously need to be logged into your cloud foundry instance. The cf CLI should then kick of the process to deploy your application on Cloud Foundry.

The important file in the directory for this is the Procfile file, it specifies what command is required to run the Python application in the container.

Running

Browse to the URL presented back you after the cf push command has complete.

To check it's running issue the cf apps command;

tmp/vote-app-flask [ cf apps                                                                                                                             master ] 3:44 PM
Getting apps in org ######## / space redwards as ##########...
OK

name        requested state   instances   memory   disk   urls
br-coffee   started           1/1         512M     512M   br-coffee.cfapps.io

To get more detail about the running app use the cf app <app name> command;

tmp/vote-app-flask [ cf app br-coffee                                                                                                                    master ] 3:44 PM
Showing health and status for app br-coffee in org ####### / space redwards as #########...
OK

requested state: started
instances: 1/1
usage: 512M x 1 instances
urls: br-coffee.cfapps.io
last uploaded: Wed Feb 1 14:51:03 UTC 2017
stack: cflinuxfs2
buildpack: python 1.5.14

     state     since                    cpu    memory          disk           details
#0   running   2017-02-01 03:16:01 PM   0.0%   16.5M of 512M   116M of 512M

Remove

To remove the application if you no longer need it run cf delete <app name>;

tmp/vote-app-flask [ cf delete br-coffee             master ] 3:41 PM

Really delete the app br-coffee?> y
Deleting app br-coffee in org ####### / space redwards as ##########...
OK

Docker

NOTE: Since migrating the voting component to an individual repo this need to be be retested. A working version is here.

Download Docker for Mac or Windows.

git clone https://github.com/clijockey/vote-app-flask.git
cd vote-ap-flask
docker build -t br-coffee .

The app will be running at http://localhost:5000.

Architecture

This repo holds the front-end voting compoents however the following architecture is what I had in mind. You can see a single repo here Architecture diagram

  • A Python webapp which lets you vote between two options
  • A Redis queue which collects new votes
  • A .NET worker which consumes votes and stores them in…
  • A Postgres database backed by a Docker volume
  • A Node.js webapp which shows the results of the voting in real time

Credit

I have to give credit to a number of different sources. Firstly I used as the base of my voting app something that Docker created and adapted a bootstrap theme called freelancer.

simple-app's People

Contributors

sapientcoffee avatar

Watchers

 avatar

simple-app's Issues

Resdis

Not yet got the Redis configuration done

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.