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
""" | |
System support for login / authentication. | |
Applications POST to login to obtain an access token, | |
which they provide in the header of subsequent requests. | |
e.g. | |
def login(): | |
post_uri = 'http://localhost:5656/api/authentication-User/login' | |
post_data = {"username": "_user_","password": "_password_"} |
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 python | |
# run: | |
# $ FLASK_APP=mini_app flask run | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from safrs import SAFRSBase, SAFRSAPI | |
db = SQLAlchemy() | |
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 python | |
# run: | |
# $ FLASK_APP=mini_app flask run | |
from flask import Flask, request | |
from flask_sqlalchemy import SQLAlchemy | |
from safrs import SAFRSBase, SAFRSAPI | |
db = SQLAlchemy() | |
def post_hook(func): |
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
{ | |
"api_root": "//thomaxxl.pythonanywhere.com/api", | |
"resources": { | |
"People": { | |
"type": "Person", | |
"search_cols": [ | |
"name" | |
], | |
"user_key": "name", | |
"columns": [ |
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
""" | |
SAFRS example calling a postgres TVF. | |
Suppose the database has this function defined: | |
--- | |
CREATE FUNCTION public.f_2(v1 integer, OUT v2 integer, OUT v3 integer) RETURNS record | |
LANGUAGE plpgsql | |
AS $$ |
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 python | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from safrs import SAFRSBase, SAFRSAPI, jsonapi_attr | |
db = SQLAlchemy() | |
class User(SAFRSBase, db.Model): |
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 python | |
# run: | |
# $ FLASK_APP=mini_app flask run | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from safrs import SAFRSBase, SAFRSAPI, jsonapi_rpc | |
import datetime | |
db = SQLAlchemy() |
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_sqlalchemy import SQLAlchemy | |
from sqlalchemy import func | |
from geoalchemy2 import Geometry | |
from flask_sqlalchemy import SQLAlchemy | |
from safrs import SAFRSBase, SAFRSAPI | |
from flask.json import JSONEncoder | |
from flask import jsonify | |
import shapely_geojson | |
from safrs.json_encoder import SAFRSJSONEncoder |
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 React from 'react' | |
class JAObject { | |
constructor(id, attributes, relationships){ | |
this.id = id // todo: check if the object with this id already exists in the redux store or the backend API | |
this._attributes = attributes // this contains both attributes and relationships | |
// TODO: add to redux store and save to jsonapi-backend | |
for(let attr_name of Object.keys(attributes || {})){ |
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 sys | |
from flask import Flask, redirect | |
from flask_sqlalchemy import SQLAlchemy | |
from flask_swagger_ui import get_swaggerui_blueprint | |
from flask_cors import CORS | |
from sqlalchemy import Column, String, ForeignKey | |
from flask_admin import Admin | |
from flask_admin import BaseView | |
from flask_admin.contrib import sqla |