mongodb-tornado-angular Documentation

Similar documents
Signals Documentation

Flask Slither Documentation

kiss.py Documentation

Hands on Angular Framework

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

Django-CSP Documentation

P a g e 1. Danish Technological Institute. Scripting and Web Languages Online Course k Scripting and Web Languages

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. TurboGears

django-baton Documentation

Unit 3 - Week 2 lectures: Building your webapp

h5serv Documentation Release 0.1 HDFGroup

a Very Short Introduction to AngularJS

Django-frontend-notification Documentation

Unifer Documentation. Release V1.0. Matthew S

MEAN Stack. 1. Introduction. 2. Foundation a. The Node.js framework b. Installing Node.js c. Using Node.js to execute scripts

flask-dynamo Documentation

django-baton Documentation

Full Stack Web Developer

Angular 2 Programming

django-reinhardt Documentation

Python wrapper for Viscosity.app Documentation

Python simple arp table reader Documentation

The RestructuredText Book Documentation

A Sample Approach to your Project

Getting MEAN. with Mongo, Express, Angular, and Node SIMON HOLMES MANNING SHELTER ISLAND

Python Project Example Documentation

Full Stack Web Developer

GMusicProcurator Documentation

Brunch Documentation. Release Brunch team

Roman Numeral Converter Documentation

Overview of Web Application Development

TPS Documentation. Release Thomas Roten

Installing PHP on Windows 10 Bash and Starting a Local Server

AngularJS Intro Homework

Python Schema Generator Documentation

Django PAM Documentation

Lab 1 - Introduction to Angular

Wifiphisher Documentation

TangeloHub Documentation

Google Domain Shared Contacts Client Documentation

How to start with 3DHOP

Overview

Trunk Player Documentation

django-session-security Documentation

Extra Notes - Data Stores & APIs - using MongoDB and native driver

Introduction to WEB PROGRAMMING

IoC Documentation. Release Thomas Rabaix

Index. Elad Elrom 2016 E. Elrom, Pro MEAN Stack Development, DOI /

BanzaiDB Documentation

Comprehensive AngularJS Programming (5 Days)

I hate money. Release 1.0

Tools. SWE 432, Fall Design and Implementation of Software for the Web

Managing Infrastructure with Python, Fabric and Ansible. By Tim Henderson hackthology.com github.com/timtadh

Aldryn Installer Documentation

Building a Django Twilio Programmable Chat Application

Flask restful swagger Documentation

Tornado-Babel Documentation

CodeValue. C ollege. Prerequisites: Basic knowledge of web development and especially JavaScript.

ClickToCall SkypeTest Documentation

pynojo Documentation Release unknown pynojo development team

Frontend UI Training. Whats App :

Silpa Documentation. Release 0.1. Santhosh Thottingal

Technical Note: On The Usage and Development of the AWAKE Web Server and Web Applications

Advanced Angular & Angular 6 Preview. Bibhas Bhattacharya

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

diceware Documentation

Aircrack-ng python bindings Documentation

pyldavis Documentation

CS193X: Web Programming Fundamentals

h5serv Documentation Release 0.1 HDFGroup

termite Release 0.0.2

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

,

Simple libtorrent streaming module Documentation

OpenUpgrade Library Documentation

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

newauth Documentation

Adventures with BaseX and web applications. Andy Feb 2013

withenv Documentation

Front-End UI: Bootstrap

Uninstall A Apps Windows 8 Programming Using Html5 Jump Start

chatterbot-weather Documentation

Kivy Designer Documentation

Patch Server for Jamf Pro Documentation

Catbook Workshop 1: Client Side JS. Danny Tang

DIGIT.B4 Big Data PoC

KonaKart Shopping Widgets. 3rd January DS Data Systems (UK) Ltd., 9 Little Meadow Loughton, Milton Keynes Bucks MK5 8EH UK

Stepic Plugins Documentation

PyCon APAC 2014 Documentation

Assignment: Seminole Movie Connection

MongoDB. Database Initialization. Note

Index. Bessel function, 51 Big data, 1. Cloud-based version-control system, 226 Containerization, 30 application, 32 virtualize processes, 30 31

web.py Tutorial Tom Kelliher, CS 317 This tutorial is the tutorial from the web.py web site, with a few revisions for our local environment.

pyramid_assetmutator Documentation

Web Development for Dinosaurs An Introduction to Modern Web Development

MASTERS COURSE IN FULL STACK WEB APPLICATION DEVELOPMENT W W W. W E B S T A C K A C A D E M Y. C O M

docs-python2readthedocs Documentation

Chapter 1 - Development Setup of Angular

Django Groups Manager Documentation

EnhancedEndpointTracker Documentation

Transcription:

mongodb-tornado-angular Documentation Release 0.1.1 David Levy February 22, 2017

Contents 1 Installation 3 1.1 linux/mac................................................. 3 1.2 Python3.x................................................. 3 1.3 Python2.x................................................. 3 2 Tutorial 5 2.1 Step 1 - basic tornado application.................................... 5 2.2 Step 2 - look and feel - bootstrap..................................... 5 2.3 Step 3 - adding angular.......................................... 5 2.4 Step 4 - mongodb............................................. 6 2.5 Step 5 - REST Angular & Tornado................................... 7 3 Getting Started 9 3.1 Software installation........................................... 9 4 Auto generated documentation 11 5 Indices and tables 13 i

ii

mongodb-tornado-angular Documentation, Release 0.1.1 Contents: Contents 1

mongodb-tornado-angular Documentation, Release 0.1.1 2 Contents

CHAPTER 1 Installation if you do not have python installed and access to a mongodb database please refer to install software later linux/mac Python3.x git clone cd mongodb-tornado-angular which python3 virtualenv distribute -p YOUR_PYTHON_PATH. source bin/activate pip install -r requirements.txt cd server python app.py Python2.x git clone cd mongodb-tornado-angular virtualenv. source bin/activate pip install -r requirements.txt cd server python app.py Windows * TBD: 3

mongodb-tornado-angular Documentation, Release 0.1.1 4 Chapter 1. Installation

CHAPTER 2 Tutorial In this tutorial we are going to learn how use the mongodb-tornado-angular framework To get started with the please clone the project and checkout your current step $ git clone https://github.com/davidvoler/mongodb-tornado-angular.git $ cd mongodb-tornado-angular/tutorial Step 1 - basic tornado application In this step you are going to create a basic tornado application, We load the index.html from templates directory. cd step1/server python app.py Step 2 - look and feel - bootstrap To improve our look and feel lets add bootstrap. for more information about bootstrap http://getbootstrap.com/ cd step2/server python app.py We are loding bootstrap css file from maxcdn <link href= //maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css rel= stylesheet > The syntax href=// will load the right protocol - http or https. We have created simple bootstrap style menu and used the container and jumbotron css class Tasks 1. Add some more bootsrap components # alert # well # forms and form groups 1. Add a bootstrap modal window http://getbootstrap.com/javascript/#modals Step 3 - adding angular #TODO - this step should be separated to 2 or more steps Now it is time to add angualrjs First lets add the angularjs code from CDN : We add the angualrjs library code to the end of the body in the index.html <script src= //cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js ></script> 5

mongodb-tornado-angular Documentation, Release 0.1.1 Lets create a new directory: client where we are going to store our own javascript code and html partial files. in the client directory we create 2 more directories js - for javascript files partials - for html snippets In this step all our js code will reside in a single file js/my_app.js As our js is loaded locally - we need to load it from the tornado server. We can use the static_path parameter for tornado: now after we have loaded angularjs code lets add our javascript file <script src= /static/js/app.js ></script> explanation for the static syntax static_path=os.path.join(os.path.dirname( file ),.., client ), os.path.dirname( file ) returns current directory os.path.join - makes sure that this will work on windows as well as on unix like system on windows we will have to write: static_path=os.path.join(os.path.dirname( file ),..\client ), on linux or mac static_path=os.path.join(os.path.dirname( file ),../client ), using os.path.join we make sure that the path will be correct on on both windows and linux Tasks: Add a partial page called help.html to partials Add a controller for this page Add a menu for this page Add routing to this page Step 4 - mongodb We are now going to start using mongodb. Read more about mongodb here: http://docs.mongodb.org/manual/core/introduction/ You can use a gui database viewer such as robomongo for data manipulation http://robomongo.org/ or simply use the default shell. for using the default shell, type mongo in a terminal (or command prompt on windows) Switch to mat database (create it if not exited already) Create blog collection Add some blog documents Please note that when accessing the database through mongo cli we use the javascript api which is slightly different from the python api. use mat db.createcollection('blog') db.blog.insert({title:'citylife',body:'i need a vacation'}) db.blog.insert({title:'fall',body:'must be spring in Australia'}) now lets read the documents.. code-block:: bash use mat db.blog.find() As we access mongodb from python/tornado we are going to use the python api - pymongo Let s add mongodb connection code to our server.. code-block:: bash import pymongo mongo_client = pymongo.mongoclient( localhost:27017 ) db = mongo_client[ mat ] Now lets add a tornado WebHandler that will handle blog read (later it will handle also write, delete and insert) 6 Chapter 2. Tutorial

mongodb-tornado-angular Documentation, Release 0.1.1 class BlogHandler(web.RequestHandler): def get(self): from bson.json_util import dumps self.write(dumps(db['blog'].find())) The function db[ blog ].find() will read all reacords from blog collection dumps will convert the data to json format self.write - will write the data to the client ( the browser) Now we have to tell the tornado server how to handle blog requests app = tornado.web.application([ (r'/', IndexHandler), # we add this line (r'/api/blog', BlogHandler), lets start our server python app.py open a browser at the following address http://localhost:9915/api/blog We get the following data which is a json representation of the documents in blog collection [{ body : I need a vacation!!!, title : Citylife, _id : { $oid : 5420f866057bc28085b0e2f9 }}, { body : Must be spring in Australia, title : Fall, _id : { $oid : 5420fe64057bc28085b0e2fa }}] In the next step we will learn how to handle this data in angular - that is how to write REST for angular tornado Questions: Where did the _id field came from? we did not add this field when creating the document? Step 5 - REST Angular & Tornado 2.5. Step 5 - REST Angular & Tornado 7

mongodb-tornado-angular Documentation, Release 0.1.1 8 Chapter 2. Tutorial

CHAPTER 3 Getting Started Software installation 9

mongodb-tornado-angular Documentation, Release 0.1.1 10 Chapter 3. Getting Started

CHAPTER 4 Auto generated documentation Contents: 11

mongodb-tornado-angular Documentation, Release 0.1.1 12 Chapter 4. Auto generated documentation

CHAPTER 5 Indices and tables genindex modindex search 13