boto3 # aws sdk
requests # to download dynamodb
mirakuru # monitors the subprocess and checks for an open port
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
import secrets | |
from typing import Union | |
from flask import Flask, Blueprint, Response, request | |
class BasicAuth: | |
def __init__(self, app: Union[Flask, Blueprint], username: str, password: str): | |
self.app = app | |
self.username = username |
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 bash | |
# put into .profile.d/ | |
LICENSE_KEY=$(echo $VCAP_SERVICES | jq -r '.[] | select(.[].name | contains("newrelic"))| .[0].credentials.licenseKey') | |
if test -z "$LICENSE_KEY" | |
then | |
echo "INFO: No New Relic service bound to app" | |
else | |
echo "INFO: New Relic service found" |
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
# Timer for functions | |
from functools import wraps | |
def timeit(f): | |
@wraps(f) | |
def wrap(*args, **kwargs): | |
start = time() | |
r = f(*args, **kwargs) | |
print(f.__name__, time() - start) |
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.json import JSONEncoder | |
class EnhancedJSONEncoder(JSONEncoder): | |
def default(self, o): | |
if dataclasses.is_dataclass(o): | |
return dataclasses.asdict(o) | |
return super().default(o) |
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 threading import Thread | |
import pytest | |
import requests | |
from flask import Flask | |
@pytest.fixture() | |
def app() -> Flask: | |
host = 'localhost' |
OlderNewer