Skip to content

Instantly share code, notes, and snippets.

View Sean-Bradley's full-sized avatar
📰
https://sbcode.net

SBCODE Sean-Bradley

📰
https://sbcode.net
View GitHub Profile
def __init__(self):
# initialize the successor chain
self.chain1 = Dispenser50()
self.chain2 = Dispenser20()
self.chain3 = Dispenser10()
# set the chain of responsibility
# The Client may compose chains once or
# the hadler can set them dynamically at
# handle time
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Seans-TypeScript-NodeJS-CRUD-REST-API-Boilerplate",
"description": "A minimal and easy to follow example of what you need to create a CRUD style API in NodeJs using TypeScript",
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
APP = Flask(__name__)
### swagger specific ###
SWAGGER_URL = '/swagger'
API_URL = '/static/swagger.json'
SWAGGERUI_BLUEPRINT = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={
'app_name': "Seans-Python-Flask-REST-Boilerplate"
{
"openapi": "3.0.0",
"info": {
"description": "sean",
"version": "1.0.0",
"title": "Seans-Python3-Flask-Rest-Boilerplate",
"contact": {
"email": "[email protected]"
},
"license": {
{
"openapi": "3.0.0",
"info": {
"description": "sean",
"version": "1.0.0",
"title": "Seans-Python3-Flask-Rest-Boilerplate",
"contact": {
"email": "[email protected]"
},
"license": {
...
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"servers": [
{
"url": "/"
...
"tags": [
{
"name": "Book Request",
"description": "Example API for requesting and return book requests"
}
],
"paths": {
"/request": {
{
"openapi": "3.0.0",
"info": {
"description": "sean",
"version": "1.0.0",
"title": "Seans-Python3-Flask-Rest-Boilerplate",
"contact": {
"email": "[email protected]"
},
"license": {
from flask import Flask, Response, stream_with_context
import time
import uuid
import random
APP = Flask(__name__)
@APP.route("/very_large_request/<int:rowcount>", methods=["GET"])
def get_large_request(rowcount):
import requests
import psycopg2
with requests.get("http://127.0.0.1:5000/very_large_request/100000000", stream=True) as r:
conn = psycopg2.connect(dbname="stream_test",
user="postgres", password="postgres")
cur = conn.cursor()
sql = "INSERT INTO transactions (txid, uid, amount) VALUES (%s, %s, %s)"