This file contains 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/env python2 | |
import requests | |
from tqdm import tqdm | |
import re | |
import os | |
def download_file_from_google_drive(id, destination): | |
URL = 'https://docs.google.com/uc?export=download' | |
session = requests.Session() |
This file contains 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 flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext import admin | |
from wtforms import TextAreaField | |
from wtforms.widgets import TextArea | |
from flask.ext.admin.contrib.sqla import ModelView | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = '123456790' |
This file contains 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
# To override flask-security's API response add the following into your app's configure_security(): | |
@app.after_request | |
def after_request(response): | |
"""Convert flask-security response into a format we can use | |
Flask-security returns | |
{'meta': {'code': 200}, 'response': { 'user': {...} } | |
But we need {'code': 200, 'data': {'user': ...} } | |
""" |
This file contains 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
@admin_api.route('/help', methods=['GET']) | |
def routes_info(): | |
"""Print all defined routes and their endpoint docstrings | |
This also handles flask-router, which uses a centralized scheme | |
to deal with routes, instead of defining them as a decorator | |
on the target function. | |
""" | |
routes = [] | |
for rule in app.url_map.iter_rules(): |
This file contains 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
#!/bin/bash | |
set -ex | |
now=$(date -u +%Y%m%d%H%M%S) | |
dest_dir="/tmp/" | |
dest_file="query_$now.json" | |
# Export your documents with a query | |
mongoexport --db YOURDB --username USERNAME --password PASSWORD --collection media \ |