from flask import Flask, g from flask_alchy import Alchy from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth from flask_restful import Api, Resource, reqparse, fields, marshal_with, abort from model.User import Model, User from itsdangerous import TimedJSONWebSignatureSerializer as JWT app = Flask(__name__) app.config['SECRET_KEY'] = 'change-me-user!!!!!' app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@postgres:5432/postgres' app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = Alchy(app, Model=Model) db.create_all() api = Api(app) auth = HTTPBasicAuth() token_auth = HTTPTokenAuth(scheme='Token') jwt = JWT(app.config['SECRET_KEY'], expires_in=6000) user_parser = reqparse.RequestParser() user_parser.add_argument('username', required=True, help='username cannot be blank') user_parser.add_argument('password', required=True, help='password cannot be blank') user_resource_fields = {'id': fields.Integer, 'username': fields.String}
BOOTSTRAP_SERVE_LOCAL = 'FLASK_DEBUG' in os.environ # database SQLALCHEMY_DATABASE_URI = os.environ['SQLALCHEMY_DATABASE_URI'] if 'mysql' in SQLALCHEMY_DATABASE_URI: # pragma: no cover SQLALCHEMY_POOL_RECYCLE = 3600 SQLALCHEMY_TRACK_MODIFICATIONS = False # user management GOOGLE_OAUTH_CLIENT_ID = os.environ['GOOGLE_OAUTH_CLIENT_ID'] GOOGLE_OAUTH_CLIENT_SECRET = os.environ['GOOGLE_OAUTH_CLIENT_SECRET'] USER_DATABASE_PATH = os.environ['USER_DATABASE_PATH'] app.config.from_object(__name__) db = Alchy(Model=Model) user = UserManagement(db, User) @app.route('/') def index(): """Dashboard view.""" metadata = Metadata.query.first() if not current_user.is_authenticated: return render_template('index.html', metadata=metadata) recent_query = api.analyses(status='completed').limit(10) fail_query = api.analyses(status='failed').filter_by(is_visible=True) running_query = api.analyses(status=['running', 'pending']) return render_template('dashboard.html', fails=fail_query, runnings=running_query, recents=recent_query,
# -*- coding: utf-8 -*- """Extensions module. Each extension is initialized in the app factory located in app.py """ from chanjo.store.models import BASE from flask_alchy import Alchy api = Alchy(Model=BASE)
from model.User import Model, Location app = Flask(__name__) app.config['SECRET_KEY'] = 'change-me-location!!!!!' app.config['USER_SERVICE_URL'] = 'http://*****:*****@postgres:5432/postgres' # app.config['USER_SERVICE_URL'] = 'http://192.168.99.100:5000/api/me' # app.config['HOST'] = '127.0.0.1' app.config['PORT'] = '5001' app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@192.168.99.100:5432/postgres' app.config['OPENWEATHERMAP_SERVICE_URL'] = 'http://api.openweathermap.org/data/2.5/' app.config['OPENWEATHERMAP_API_KEY'] = '0c77231223df5bae357bd2bd85104554' app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = Alchy(app, Model=Model) db.create_all() api = Api(app) auth = HTTPTokenAuth(scheme='Token') location_parser = reqparse.RequestParser() location_parser.add_argument('address_type', required=True, help='address_type cannot be blank') location_parser.add_argument('address', required=True, help='address cannot be blank') location_get_parser = reqparse.RequestParser() location_get_parser.add_argument('address_type', required=True, help='address_type cannot be blank', location='args') location_get_parser.add_argument('address', required=True, help='address cannot be blank', location='args') location_resource_fields = {
from flask import Flask, session from flask_alchy import Alchy from flaskery.switches.state import SwitchesState from flaskery.switches.switches import switches_app HELP_TEXT = """\ Silly demo app for stomping around Flask.""" # The WSGI thingo. app = Flask(__name__) # The configuration. app.config.from_object('config') # The database. db = Alchy(app, Model=SwitchesState) # The switches module. app.register_blueprint(switches_app) # Let there be data. db.create_all() # Make sessions have a timeout. @app.before_request def make_session_permanent(): session.permanent = True def main(): """ Parse arguments and get things going for the web interface """ parser = argparse.ArgumentParser(description=HELP_TEXT)