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 fnmatch | |
import os | |
imagens = ['*.jpg', '*.jpeg', '*.png', '*.tif', '*.tiff'] | |
achados = [] | |
for raiz, diretórios, arquivos in os.walk("C:\\"): | |
for extensões in imagens: | |
for arq in fnmatch.filter(arquivos, extensões): | |
print (raiz + '\\' + arq) |
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.request | |
import json | |
from pprint import pprint | |
class Dic42(dict): | |
def __missing__(self, key): | |
return '42' | |
url = 'https://graph.facebook.com/fmasanori' | |
resp = urllib.request.urlopen(url).read() |
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 | |
url = 'http://api.icndb.com/jokes/random?limitTo=[nerdy]' | |
resp = urllib.urlopen(url).read() | |
data = json.loads(resp) | |
print (data['value']['joke']) |
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
#deprecated with in 30 April, 2015, with new 2.0 Facebook API | |
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 MongoClient | |
connection = MongoClient("mongodb://localhost") | |
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 MongoClient | |
connection = MongoClient("mongodb://localhost") | |
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.MongoClient("mongodb://localhost") | |
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' |
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) |