Building Python web app on GAE

Similar documents
webapp2 Documentation

App Engine Web App Framework

App Engine Web App Framework

CS2021- Week 10 Models and Views. Model, View, Controller. Web Development Model, Views, Controller Templates Databases

Jaesun Han (NexR CEO & Founder)

Hons. B.Sc. Degree in Software Engineering/Development. Web and Cloud Development

CS2021-Week 9 - Forms. HTML Forms. Python Web Development. h?ps:// cs253/unit-2html. Form for Submitting input:

한재선 KAIST 정보미디어경영대학원겸직교수 & NexR 대표이사

Chapter 19: Twitter in Twenty Minutes

Google & the Cloud. GData, Mashup Editor, AppEngine. Gregor Hohpe Software Engineer Google, Inc. All rights reserved,

CS4HS Using Google App Engine. Michael Parker

Google App Engine Using Templates

Rapid Development with Django and App Engine. Guido van Rossum May 28, 2008

Google Maps Samples. Google Maps Samples 2012

welcome to BOILERCAMP HOW TO WEB DEV

Installing and Running the Google App Engine On a Macintosh System

CCS Lab FAQ: Using Google App Engine to host websites

HTML5 and CSS3 JavaScript Advanced Features Page 1

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.

Google App Engine Data Store. Google is BIG. Advanced Stuff.

In this project, you ll learn how to create your own webpage to tell a story, joke or poem. Think about the story you want to tell.

django-sticky-uploads Documentation

Anatomy of a SPA: Client-side MVC

webkitpony Documentation

Unable To Access An Error Message Corresponding To Your Field Name. Codeigniter Callback

Building a Django Twilio Programmable Chat Application


Building and packaging mobile apps in Dreamweaver CC

django-ad-code Documentation

Building Production Quality Apps on App Engine. Ken Ashcraft 5/29/2008

CSCU9B2 Practical 8: Location-Aware Web Pages NOT USED (DOES NOT ALL WORK AS ADVERTISED)

django-session-security Documentation

GMusicProcurator Documentation

CIW 1D CIW JavaScript Specialist.

Evolution of the "Web

Unifer Documentation. Release V1.0. Matthew S

Web applications Developing Android/Iphone Applications using WebGUI

BXG BLUX Game Engine Getting Started BXG Getting Started

Alert. In [ ]: %%javascript alert("hello");

Pop-up. File format/ size: Must provide (.gif or.jpg) still image - max. 75KB for Mobile - max. 400KB for Tablet

CIS192 Python Programming

Building Scalable Web Apps with Python and Google Cloud Platform. Dan Sanderson, April 2015

Design Document V2 ThingLink Startup

CSE 115. Introduction to Computer Science I

GPS Device API Guide Program

Writing Web Apps in C++? Eric Bidelman, Google COSCUP / GNOME.Asia - Taipei, Taiwan August 14, 2010

Framework7 and PhoneGap. By Lars Johnson

Jquery Ajax Json Php Mysql Data Entry Example

Google Maps Manually Place Marker On Click V3 Remove

AngularJS Intro Homework

HTML5 Applications Made Easy on Tizen IVI. Brian Jones / Jimmy Huang

After signing in, click on the grid icon and then click on Drive from the Google app menu.

Homework #7 Google Cloud Platform

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

django-xross Documentation

Manual Html A Href Onclick Submit Form

django-ajax-form-mixin Documentation

Developing Apps for the BlackBerry PlayBook

Getting Started with HTML5 using BlackBerry WebWorks

Introducing FTP and HTTP Updated: 9/25/18

Süddeutsche Zeitung, Digital Edition

This is CS50 CS164. Mobile Software Engineering

Client Side JavaScript and AJAX

Serverless Single Page Web Apps, Part Four. CSCI 5828: Foundations of Software Engineering Lecture 24 11/10/2016

Databases/JQuery AUGUST 1, 2018

Meet Mojo. Jesse Donaldson Sr. Manager, Mojo Framework

Building OSM based web app from scratch

nacelle Documentation

Technical Requirements

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

Table JESSICA MILLER WCLS COORDINATOR

django-inplaceedit Documentation

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

Building a Simple Mobile optimized Web App/Site Using the jquery Mobile Framework (part 2)

Creative Techniques for Loading Web Pages Faster

Slug: HTML5 for Mobile Web Applications, ISBN number, 23! kyrnin hour23-code.doc

Tutorials Php Y Jquery Mysql Database Without Refreshing Code

Marketo Forms Integration Guide

Developing with Google App Engine

Statirator Documentation

Manual Html Image Src Url Path Not Working

widgets, events, layout loosely similar to Swing test browser, or plugin for testing with real browser on local system

GPS Device API Guide Program

Django-CSP Documentation

5/19/2015. Objectives. JavaScript, Sixth Edition. Using Touch Events and Pointer Events. Creating a Drag-and Drop Application with Mouse Events

Working Bootstrap Contact form with PHP and AJAX

About Sven. Using Groovy & Grails since Aug 2006 Grails Podcast, Groovy Series Working at Yahoo!, Inc. Find out yourself

Mobile Technologies. Types of Apps

ThingLink User Guide. Andy Chen Eric Ouyang Giovanni Tenorio Ashton Yon

Lab 1: Introducing HTML5 and CSS3

wagtailmenus Documentation

Dreamweaver CS6. Table of Contents. Setting up a site in Dreamweaver! 2. Templates! 3. Using a Template! 3. Save the template! 4. Views!

Homework 9: Stock Search Android App with Facebook Post A Mobile Phone Exercise

Homework 8: Ajax, JSON and Responsive Design Travel and Entertainment Search (Bootstrap/Angular/AJAX/JSON/jQuery /Cloud Exercise)

Configuring Anonymous Access to Analysis Files in TIBCO Spotfire 7.5

Building Native Mapping Apps with PhoneGap: Advanced Techniques Andy

VS005 - Cordova vs NativeScript

Understanding the Dumper Program Google Application Engine University of Michigan Informatics

28 JANUARY, Updating appearances. WordPress. Kristine Aa. Kristoffersen, based on slides by Tuva Solstad and Anne Tjørhom Frick

we're telling PHP to convert the contents of a file (in this case, Apple's server. Curl Error Code 19 Payload File Is Missing

Transcription:

Building Python web app on GAE tw3gsucks, a 3G network speed test web app. PyHUG Tsai, Shih-Chang 2011/12/21

It all starts with... 3G network is really SUCKS!!! I'm used to live in a connected world! Bad network quality/bandwidth makes me crazy!!!

Is there anything I can do? Yes! But maybe we can do it more interestingly!

Google Map! Bandwidth data alone is really boring. What if we put these data on maps?

tw3gsucks project profile Open source project Url: http://tw3gsucks.appspot.com Github - https://github.com/jacksctsai/tw3gsucks

How tw3gsucks works

GAE is good place to start! Google Application Engine https://appengine.google.com/ Python natively supported - Good! Database support - Good! Given a domain name like yourapp.appspot.com - Even better! Tutorials, many documents & sample code It's all FREE & Ready to go! - Huge Win!!!

Techniques involved HTML5 - GPS support jquery - Controlling UI & download sample data Python + Django - Service side programming GAE - App hosting & Database support Google Map - Showing map Github - Version control these are all new to me... :P

GAE - Get Started A google ID (of course.) GAE SDK is a beginner's good friend! Download GAE SDK at http://code.google.com/intl/zh-tw/appengine/downloads.html

A Sample Application More info on app.yaml goto: http://code.google.com/intl/zh-tw/appengine/docs/python/config/appconfig.html

A basic GAE python program import os from google.appengine.ext.webapp import template from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): template_values = { 'key': value } path = os.path.join(os.path.dirname( file ), 'index.html') self.response.out.write(template.render(path, template_values)) application = webapp.wsgiapplication([ ('/', MainPage) ], debug=true) def main(): run_wsgi_app(application) if name == ' main ': main()

app.yaml for tw3gsucks application: tw3gsucks version: 1 runtime: python api_version: 1 inbound_services: - warmup handlers: - url: /css static_dir: css - url: /payload static_dir: payload - url: /showmap script: signalreportgen.py - url: /favicon.ico static_files: static/images/favicon.ico upload: static/images/favicon.ico - url: /.* script: reportsignal.py

Location - enabling GPS <html> <script> function locationgot(position) { $("#require_gps").hide(); $("input[name='location']").val(position.coords.latitude+', ' + position.coords.longitude); $("#reportpanel").fadein(); test(); } $(".msg").hide(); $(".result").hide(); if (navigator.geolocation) { $("#require_gps").fadein(); navigator.geolocation.getcurrentposition(locationgot); } else { } </script> </html>

Bandwidth detection This is a little bit tricky. <html> <script> var time1; var bytesloaded = 499717; function test() { $(":submit").attr("disabled", true); var d = new Date; time1 = d.gettime(); $.get( 'payload/speedtestpayload.html', function(obj) { var d = new Date; var time = Math.round((d.getTime()-time1)/10)/100; // 取秒以下兩位小數 var connspeed = Math.round (bytesloaded/time/1000); // 單位 :Kbytes per second $("input[name='speed']").val(connspeed); $(":submit"). attr("disabled", false); } ); } </script> </html>

Storing data on GAE database Create Data Model: from google.appengine.ext import db class SignalReport(db.Model): """Models an individual signal report entry, geolocation, connection info, ip address, and date.""" location = db.geoptproperty() speed = db.integerproperty() tech = db.stringproperty() provider = db.stringproperty() ip = db.stringproperty() date = db.datetimeproperty(auto_now_add=true)

Storing data on GAE database Save data: import os from google.appengine.ext import webapp from google.appengine.ext import db class MainPage(webapp.RequestHandler): def get(self): path = os.path.join(os.path.dirname( file ), 'index.html') self.response.out.write(template.render(path, [])) def post(self): location = self.request.get('location').split(', ') provider_tech = self.request.get('provider_tech').split(' ') // provider_tech is like 中華電信 3G speed = self.request.get('speed') signalreport = SignalReport() if speed.isdigit(): signalreport.speed = int(speed) signalreport.location = db.geopt(lat = location[0], lon=location[1]) signalreport.tech = provider_tech[1] signalreport.provider = provider_tech[0] signalreport.ip = self.request.remote_addr signalreport.put()

Retrieving data and applying template class ShowMap2Page(webapp.RequestHandler): def get(self): signal_query = SignalReport.all() signals = signal_query.fetch(signal_query.count()) template_values = { 'signals': signals } path = os.path.join(os.path.dirname( file ), 'showmaptest.html') self.response.out.write(template.render(path, template_values))

Integrating Google Map <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var mylatlng = new google.maps.latlng({{ signal.location.lat }}, {{ signal.location.lon }}); var contentstring = '<div id="content">'+ '<div id="landmarknotice">'+ '<img src=badimage />'+ ' 實測每秒 {{ signal.speed }} KB ({{ signal.provider }} {{ signal.tech }})'+ '</div>'+ '<p> {{ signal.datestr }}</p>'+ '<p><font size="-1"> 經緯度 :{{ signal.location.lon }},{{ signal.location.lat }}</font></p>'+ '</div>'; var infowindow = new google.maps.infowindow({ content: contentstring }); var marker = new google.maps.marker({ position: mylatlng, map: map, icon: BadImage, title: " 測速 {{ signal.speed }} kbps" }); google.maps.event.addlistener(marker, 'click', createenclosur(map,marker, infowindow)); </script>

Something missing Carrier identification (using IP addr, perhaps) Better map presentation

Show Time