Created
October 1, 2018 22:00
-
-
Save andrewkrug/314a19bc35ef08f35ea2b45518c3603b to your computer and use it in GitHub Desktop.
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_cors import CORS | |
from flask_graphql import GraphQLView | |
from flask_restful import Api | |
from graphene import Schema | |
from cis_profile_retrieval_service.common import get_config | |
from cis_profile_retrieval_service.common import initialize_vault | |
from cis_profile_retrieval_service.common import seed | |
from cis_profile_retrieval_service.schema import Query | |
from cis_profile_retrieval_service.schema import AuthorizationMiddleware | |
from cis_profile_retrieval_service.idp import requires_auth | |
app = Flask(__name__) | |
api = Api(app) | |
CORS(app) | |
config = get_config() | |
initialize_vault() | |
seed() | |
authorization_middleware = AuthorizationMiddleware() | |
def graphql_view(): | |
view_func = GraphQLView.as_view( | |
'graphql', | |
schema=Schema(query=Query), | |
middleware=[authorization_middleware], | |
graphiql=bool(config('graphiql', namespace='person_api', default='True')) | |
) | |
return requires_auth(view_func) | |
app.add_url_rule('/graphql', view_func=graphql_view()) | |
def main(): | |
app.run(host='0.0.0.0', debug=True) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment