Example #1
0
    app.config["DATABASE_URI"],
    poolclass=app.config["SQLALCHEMY_POOLCLASS"],
    pool_size=20,
    pool_recycle=3600,  # Recycle connections every 1 hr
    max_overflow=0,
    echo=False,
)

formatter = logging.Formatter(app.config["LOG_FORMAT"])
handler = RotatingFileHandler(app.config["LOG_FILE"])
handler.setFormatter(formatter)
handler.setLevel(app.config["LOG_LEVEL"])

app.logger.addHandler(handler)

# Add application logic to flask app (?)
app.tasks = TaskLogic(db_engine=engine)
app.register_blueprint(mod_tasks, url_prefix="/tasks")


@app.route("/")
def index():
    app.logger.info("Index called!")
    return "<h1>Ping!</h1><br /><h3>Welcome to SchedHTTP</h3>"


if __name__ == "__main__":
    try:
        app.run(host="0.0.0.0", port=6500, debug=True)
    except Exception:
        app.logger.exception("Failed")
Example #2
0
__license__ = "MIT"
__email__ = "remizoffalex@mail.ru"

import json
import os
import sys
import uuid

from flask import Flask, render_template, request, redirect, make_response
from jinja2 import Environment, FileSystemLoader

import clsmenu

app = Flask(__name__)

app.tasks = []
app.menu = clsmenu.MenuStruct()
app.menu.read_json(os.path.dirname(__file__) + "/menu.json")
app.params = []


def genjson():
    result = app.tasks
    for typeres in result:
        for typeparam in app.params:
            if typeparam["type"] == typeres["type"]:
                for actionres in typeres["actions"]:
                    for actionparam in typeparam["actions"]:
                        print >>sys.stderr, actionparam
                        if actionres["action"] == actionparam["action"]:
                            for reskey in actionparam.keys():