This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| import json | |
| from pprint import pprint | |
| url = 'https://graph.facebook.com/fmasanori' | |
| resp = urllib.urlopen(url).read() | |
| data = json.loads(resp) | |
| pprint(data) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| url = 'https://graph.facebook.com/1183621847/picture?type=large' | |
| imagem = urllib.urlopen(url).read() | |
| f = open('foto.jpg', 'wb') | |
| f.write(imagem) | |
| f.close() | |
| print ('Foto do perfil gravada...') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from pymongo import Connection | |
| connection = Connection('localhost', 27017) | |
| db = connection.test | |
| post = {"title": "My Blog Post", | |
| "content": "Here's my blog post.", | |
| "date": datetime.utcnow()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bottle | |
| import pymongo | |
| @bottle.route('/') | |
| def index(): | |
| from pymongo import Connection | |
| connection = Connection('localhost', 27017) | |
| db = connection.test | |
| names = db.names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pymongo | |
| import sys | |
| def main(): | |
| connection = pymongo.Connection('localhost', safe=True) | |
| db = connection.m101 | |
| people = db.people | |
| person = {'name': 'Barack Obama', 'role':'President', | |
| 'address':{'address1':'The White House', | |
| 'street': '1600 Pensylvania Avenue', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bottle | |
| #this is the handler for the root address on the web browser | |
| @bottle.route('/') | |
| def home_page(): | |
| return 'Hello Bottle World\n' | |
| @bottle.route('/testpage') | |
| def test_page(): | |
| return 'Oficina MongoDB e Python no FISL 2013' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bottle | |
| @bottle.route('/') | |
| def home_page(): | |
| mythings = ['apple', 'orange', 'banana', 'peach'] | |
| return bottle.template('hello_world', {'username':'Masanori', | |
| 'things':mythings}) | |
| bottle.debug(True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Hello World!</title> | |
| </head> | |
| <body> | |
| <p> | |
| Welcome {{username}} | |
| <p> | |
| <ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bottle | |
| @bottle.route('/') | |
| def home_page(): | |
| mythings = ['apple', 'orange', 'banana', 'peach'] | |
| return bottle.template('hello_world2', {'username':'Masanori', | |
| 'things':mythings}) | |
| @bottle.post('/favorite_fruit') | |
| def favorite_fruit(): | |
| fruit = bottle.request.forms.get('fruit') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Hello World!</title> | |
| </head> | |
| <body> | |
| <p> | |
| Welcome {{username}} | |
| <p> | |
| <ul> |