Example #1
0
def update_task():
    app = Flask(__name__)
    init_db(app)
    with app.app_context():
        logger = prefect.context.get("logger")
        logger.info("Checking for updates and writing any new records.")
        ensure_cve_modified_feed_is_updated()
Example #2
0
 def delete(self):
     """Сброс бд для тестирования"""
     data = request.json
     if data.get("reinit") == 1:
         os.remove("application.db")
         init_db()
     return {"status": "database recreated"}
Example #3
0
def create_app(config_name: str):

    app = Flask(app_name, instance_relative_config=True)

    init_db(app)
    register_dash(flask_app_name=app_name, flask_app=app)

    return app
Example #4
0
def register_extensions(app, worker=False):
    jwt = JWTManager(app)  # noqa
    init_db(app)
    # load celery config
    celery.config_from_object(app.config)

    if not worker:
        # register celery irrelevant extensions
        pass
Example #5
0
def init_task():
    logger = prefect.context.get("logger")
    logger.info(
        "Beginning full download and initial hydration. This will take quite awhile."
    )
    app = Flask(__name__)
    init_db(app)
    with app.app_context():

        logger.info("Downloading and hydrating cve table.")
        download_and_hydrate_cve()
Example #6
0
    def __init__(self):
        self.CONFIG = configparser.RawConfigParser()
        self.CONFIG.read('config.cfg')

        # Get Config info
        self.HOST = self.CONFIG.get('flask', 'host')
        self.PORT = int(self.CONFIG.get('flask', 'port'))

        # DB
        init_db()

        # API
        self.APP = Flask(__name__)
        self.APP.secret_key = self.CONFIG.get('flask', 'secret')
        self.APP.config['DEBUG'] = self.CONFIG.getboolean('flask', 'debug')
        APIController(self.APP).register_blueprints()
Example #7
0
def create_app():
    app.config.from_pyfile('../settings.py')

    app.static_folder = app.config.get('STATIC_FOLDER')

    app.config.update({'SITE_TIME': datetime.datetime.utcnow()})

    configure_jinja(app)

    configure_leancloud(app)

    register_routes(app)

    init_db()

    return app
Example #8
0
# -*- coding: utf-8 -*-
from db.database import init_db

__author__ = 'myth'
"""
项目安装脚本
"""


if __name__ == '__main__':
    # 数据库创建
    init_db()
Example #9
0
def create_db():
    from db.database import init_db
    init_db()
    print('建立数据库成功!')
Example #10
0
app = flask.Flask(__name__)
app.register_blueprint(roles)
app.register_blueprint(groups)
app.register_blueprint(employees)
app.register_blueprint(dashboard)
app.register_blueprint(users)

app.config['SECRET_KEY'] = "GroupAssignment_Tool_KEY374657*"

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = '/users'

# Initalize the database
init_db()


@app.before_request
def before_request():
    g.user = current_user


@login_manager.user_loader
def load_user(id):
    return query.get_user_by_id(id)


@app.route('/')
def index():
    # If there is no userName, then route to loginScreen. Else, route to the main page.
Example #11
0
# Build a list of SQL statements.
sql_statements = ["/* This file is automatically created. Anything you'll write here "
                  "will be deleted when database is setup again.*/\n",
                  build_alter_role_query(Config.DB_CONNECT_OPTIONS['username'],
                                         Config.DB_CONNECT_OPTIONS['password']),
                  build_drop_database_query(Config.DB_CONNECT_OPTIONS['dbname']),
                  build_create_database_query(Config.DB_CONNECT_OPTIONS['dbname'])]

# Write list of SQL statements to file
store_statements_into_reset_file(reset_db_path, sql_statements)

# Let's allow some time for the writing to be done.
sleep(2)

# Now we call the script we just created.
call(setup_path)

# Initialize database tables(SQLAlchemy)
database.init_db()

# Now we populate the database.

# Here's how you do it in Python 2
# execfile(populate_path)

# Here's how that's done in Python 3
with open(populate_path) as f:
    code = compile(f.read(), populate_path, 'exec')
    exec(code)
Example #12
0
def create_db():
    init_db()
Example #13
0
def create_user():
    init_db()
Example #14
0
def install_books():
    init_db()
    member = Member('admin', 'admin@localhost')
    db_session.add(member)
    db_session.commit()
Example #15
0

@app.route('/personal_color', methods=["POST"])
def get_personal_color():
    error_message = check_param(request.json, {'file': str})
    if error_message:
        abort(400, {'message': error_message})

    img = request.json['file'].encode()

    res = predict_personal_color(img)

    return jsonify(res)


if __name__ == "__main__":
    load_dotenv()
    db_config = {
        'user': os.getenv('DB_USER'),
        'password': os.getenv('DB_PASS'),
        'host': os.getenv('DB_HOST'),
        'db_name': os.getenv('DB_NAME')
    }
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://{user}:{password}@{host}/{db_name}?charset=utf8'.format(
            **db_config)
    database.init_db(app)

    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port, debug=True)
from dash.dependencies import Input, Output
from flask import Flask
import plotly.express as px

from db.database import (
    get_cvss_v2_cols,
    get_cvss_v3_cols,
    get_cve_query_df_with_columns,
    init_db,
)

temp_app = Flask(__name__)
init_db(temp_app)
with temp_app.app_context():
    full_df = get_cve_query_df_with_columns()

# This leaves some records not included because they have not been assigned versions or score information.
cve_cvss_v3_df = full_df[get_cvss_v3_cols()].loc[
    full_df["cvss_v3_version"].notna()]
cve_cvss_v2_df = full_df[get_cvss_v2_cols()].loc[
    full_df["cvss_v2_version"].notna()]

# Add x col for display
cve_cvss_v3_df["date_published"] = cve_cvss_v3_df.apply(
    lambda x: str(x["published_date"])[8:10], axis=1)

px_box_cvss_v3_base_score = {}
px_hist_cvss_v3_base_severity = {}
px_hist_cvss_v3_attack_vector = {}
px_hist_cvss_v3_attack_complexity = {}
px_hist_cvss_v3_privileges_required = {}