app.config['MYSQL_DB'] = '' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' # init MYSQL mysql = MySQL(app) __author__ = 'Oliver "othornew" Thornewill \ Adel "0x4d31" Karimi' __version__ = '0.2' # Log to stdout # On Heroku, anything written to stdout or stderr is captured into your logs. # https://devcenter.heroku.com/articles/logging logger = logging.getLogger(__name__) out_hdlr = logging.StreamHandler(sys.stdout) out_hdlr.setFormatter(logging.Formatter('%(asctime)s %(message)s')) out_hdlr.setLevel(logging.INFO) logger.addHandler(out_hdlr) logger.setLevel(logging.INFO) @app.route('/', defaults={'path': ''}) def default(path): return render_template('default.html') @app.route('/favicon.ico') def favicon(): return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon')
from flask import Flask, request, render_template, send_file, logging, redirect from flask.ext.socketio import SocketIO, emit from flask.ext.uploads import UploadSet, configure_uploads import os import services app = Flask(__name__) app.config['SECRET_KEY'] = 'secret' DEFAULT_PORT = 5000 socketio = SocketIO(app) log = logging.getLogger('run') log.setLevel(logging.DEBUG) log.addHandler(logging.StreamHandler()) photos = UploadSet() photos.file_allowed = lambda a, b: True app.config['UPLOADS_DEFAULT_DEST'] = '/tmp' configure_uploads(app, photos) @app.route('/') def index_demo(): return render_template('app.html', label_names=','.join( sorted(services.get_labels().keys()))) @app.route('/admin')
from functions.utils import base64_to_pil_image, pil_image_to_base64 app = Flask(__name__) app.config['MAIL_SERVER'] = 'smtp.gmail.com' app.config['MAIL_PORT'] = 587 app.config['MAIL_USE_TLS'] = True app.config['MAIL_USE_SSL'] = False app.config['MAIL_USERNAME'] = '******' app.config['MAIL_PASSWORD'] = os.environ.get('PASSWORD') app.config['MAIL_DEFAULT_SENDER'] = '*****@*****.**' #app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:password@localhost/db_name engine = create_engine(os.environ.get('DATABASE_URL')) db = scoped_session(sessionmaker(bind=engine)) app.logger.addHandler(logging.StreamHandler(stdout)) app.config['DEBUG'] = True socketio = SocketIO(app) mail = Mail(app) global camera global flag question_grid = [] solution_grid = [] @socketio.on('input image', namespace='/test') def test_message(input): global question_grid global solution_grid
# insert dashboard in mysql Dashboard.create(new_id, dashboard_type) # relate to the current user if it's private if dashboard_type == 'private': DashboardCommunity.add_dashboard_to_community(new_id, user.community_id) return True @app.errorhandler(500) def internal_error(exception): current_app.logger.error(exception) response = jsonify(message="Unexpected error") response.status_code = 500 return response if __name__ == '__main__': Compress(app) CORS(app) api = Api(app) db.init_app(app) config_oauth(app) app.logger.addHandler(logging.StreamHandler()) app.logger.setLevel('INFO') api.add_resource(BasicDataAccess, '/api/v0/<source>') api.add_resource(IoTWalletLoginManager, '/iotlogin/<string:source>') api.add_resource(OAuthManager, '/oauth/<string:source>') api.add_resource(CommunityManager, '/community/<string:source>') app.run(host='0.0.0.0', port=cfg['api']['v0']['port'], threaded=True, debug=False)
import os from flask import Flask, render_template, request, send_file, logging from io import BytesIO import numpy as np from PIL import Image from keras.models import Model from keras.layers import Activation, BatchNormalization, Dropout, K from keras.layers import Conv2D, MaxPooling2D, Input, UpSampling2D from keras.layers import Dense from keras.layers import GlobalAveragePooling2D import pandas from sklearn.manifold import TSNE application = Flask(__name__) application.config['TEMPLATES_AUTO_RELOAD'] = "TRUE" application.logger.addHandler(logging.StreamHandler(sys.stdout)) application.logger.setLevel(logging.ERROR) @application.route("/") def index(): return render_template("index.html") @application.route("/about") def about(): return render_template("about.html", PAGE="about") @application.route("/terms") def terms():
The script re-parses old sqlite database of the Fall 2014 format and fills conditions according to the run """ import argparse import sqlite3 import sys from flask import logging import rcdb.model from rcdb import ConfigurationProvider from rcdb import coda_parser from rcdb.file_archiver import get_file_sha256, get_string_sha256 import xml.etree.ElementTree as ET # setup logger log = logging.getLogger('rcdb') # create run configuration standard logger log.addHandler(logging.StreamHandler(sys.stdout)) # add console output for logger log.setLevel(logging.DEBUG) if __name__ == "__main__": # hello print ("This program takes sqlite file of RCDB with data taken prior 2015" \ " and add to a database with new format") # parse arguments parser = argparse.ArgumentParser() parser.add_argument("in_sqlite_file", help="Input SQLite file") parser.add_argument("out_con_string", help="Connection string to empty output database. Example: sqlite:////home/john/out.db") args = parser.parse_args() print("Arguments given: ")