from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_pushjack import FlaskAPNS from flask_pushjack import FlaskGCM from flask_apscheduler import APScheduler app = Flask(__name__) app.config.from_object('config') db = SQLAlchemy(app) # auto = Autodoc(app) clientapns = FlaskAPNS() clientapns.init_app(app) clientgcm = FlaskGCM() clientgcm.init_app(app) scheduler = APScheduler()
softheon_client = os.environ['SOFTHEON_CLIENT_ID'] softheon_secret = os.environ['SOFTHEON_CLIENT_SECRET'] DB_HOST = "localhost" PORT = '5432' APP_PORT = 3000 DB_STRING = "postgres://%s:%s@%s:%s/stim" % (DB_USER, DB_PASS, DB_HOST, PORT) # print(DB_STRING) app = Flask(__name__) app.config.update(config) # app.config.from_object(os.environ['APP_SETTINGS']) app.config['SQLALCHEMY_DATABASE_URI'] = DB_STRING app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False apns_client = FlaskAPNS() apns_client.init_app(app) CORS(app) db = SQLAlchemy(app) db.create_all() predict = Predict() ns = NotificationService() softheon = Softheon(softheon_client, softheon_secret) @app.route('/') def hello():
def add_bp(app_obj): modules_define = [ auth.app, login.app, wage.app, username.app, password.app, user.app, shiftcategory.app, notification.app, color.app, salary.app, usershift.app, table.app, comment.app, memo.app, company.app, shift.app, token.app, follow.app, export.app, search.app, analytics.app ] for bp_app in modules_define: app_obj.register_blueprint(bp_app) app = init_app() client = FlaskAPNS() client.init_app(app) admin_basic_auth = BasicAuth(app) migrate = Migrate(app, db) @app.route('/logout') def Logout(): raise AuthException('Successfully logged out.') @app.route('/') @app.route('/index') def index(): return 'This is index page'
#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import Flask from flask_bootstrap import Bootstrap from flask_sqlalchemy import SQLAlchemy from config import config from flask_login import LoginManager from flask_pushjack import FlaskAPNS bootstrap = Bootstrap() db = SQLAlchemy() client = FlaskAPNS() # 注册Flask-login login_manager = LoginManager() login_manager.session_protection = 'strong' login_manager.login_view = 'main.login' def creat_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) client.init_app(app) app.config.update( dict( APNS_CERTIFICATE='/var/www/weightingsystem/apns/apns_pro_nokey.pem', APNS_ENABLED=True, APNS_SANDBOX=False,
headers = {"Content-Type": "application/json"} data = { "wifiAccessPoints": [ {"macAddress": ap.mac_address, "signalStrength": ap.signal, "channel": ap.channel} for ap in aps ] } res = requests.post(url, headers=headers, json=data) geo = res.json() return geo["location"]["lat"], geo["location"]["lng"] # App definition app = Flask(__name__) app.config.update(config) client = FlaskAPNS() client.init_app(app) @app.route("/") def hello(): return "Hello world!" @app.route("/loc") def loc(): lat, lng = find_geolocation() return "{} {}".format(lat, lng) @app.route("/nearby")
from flask import Flask from flask_pushjack import FlaskAPNS config = {'APNS_CERTIFICATE': 'push_dev.pem'} app = Flask(__name__) app.config.update(config) client = FlaskAPNS() client.init_app(app) with app.app_context(): token = 'afb5c4ff3c153dbe30a3a04ee168030f5b5d786035f629779ad999af3786a697' # Send to single device. res = client.send(token, alert, **options) # List of all tokens sent. res.tokens # List of any subclassed APNSServerError objects. res.errors # Dict mapping token => APNSServerError. res.token_errors # Send to multiple devices. client.send([token], alert, **options) # Get expired tokens. expired_tokens = client.get_expired_tokens()
from libraries.graphLib.graphe_tbc import GraphTBC #Create Flask app server = Flask(__name__) # Import Config server.config.from_pyfile('../server.config') # SQLAlchemy db = SQLAlchemy(server) # Celery celery = make_celery(server) # Graphe G = GraphTBC() from project.libraries.celeryLib.tasks import * # FlaskLogin login_manager = LoginManager(server) # FlaskPrincipal Principal(server) # FlaskGCM clientGCM = FlaskGCM(server) # FlaskAPNS clientAPNS = FlaskAPNS(server)