Skip to content

Instantly share code, notes, and snippets.

@mathiasbc
mathiasbc / flat_mongo_json.py
Created April 30, 2017 17:12
JSON response from MongoDB bson in Flask
import json
from flask import Flask, make_response
import datetime
from bson.objectid import ObjectId
from bson.tz_util import utc
from bson import EPOCH_AWARE, SON
from bson.py3compat import iteritems
from bson.py3compat import text_type
import re
l = [[1,2,[3]],4]
print([int(x) for x in re.findall('[0-9]+', str(l))])
#!/usr/bin/python3
import requests
URL = "http://www.letsrevolutionizetesting.com/challenge.json"
def follow(url):
response = requests.get(url).json()
while 'follow' in response:
from sqlalchemy import MetaData, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import datetime
# development database credentials
DEV_DB_USER = 'some_user'
DEV_DB_PASSWORD = 'some_password'
DEV_DB_DATABASE = 'database_name'
{% macro form_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="control-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}: