Last active
January 2, 2019 00:17
-
-
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
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
#!/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:[email protected]/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