Skip to content

Instantly share code, notes, and snippets.

@Jul10l1r4
Last active January 2, 2019 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jul10l1r4/b688210bf0c0cbe13c62901b5dc0f7a9 to your computer and use it in GitHub Desktop.
Save Jul10l1r4/b688210bf0c0cbe13c62901b5dc0f7a9 to your computer and use it in GitHub Desktop.
Esse é um exemplo que faz requisição do blob de três imagens comprimidas em base64 no banco dos EUA em mongoDB
#!/usr/bin/python3
# -*- Coding: utf-8 -*-
from flask import Flask, jsonify
from pymongo import MongoClient
import os
app = Flask(__name__)
# Conectio my
client = MongoClient('mongodb://example:senha@host.com/images',45704)
db = client.images
# API work
@app.route('/')
def main ():
# Selecting colletion
collection = db['blobs']
#cursor = collection.find({})
def make(x):
# The values get information by type
return 'Fuckindata {"buf":"'+str(collection.find_one({"type":x})["data"])+'"}'
# Make a loop in cursor, in collection
blob = list(map(make,['a','b','c']))
print (blob)
return jsonify(blob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment