Example #1
0
import importlib
from flask import Flask, render_template, request, session, url_for, redirect
from common.db import Db
import hashlib

modules = "home", "rules", "movielist", "proposed_movies"

app = Flask("movienights")
app.db = Db("db/movienights.db")
app.menu = []
for module in list(modules):
    m = importlib.import_module(".".join(["modules", module]))
    blueprint = m.__dict__[module]
    if blueprint.menu is not None:
        app.menu.append(blueprint.menu)
    app.register_blueprint(blueprint)


def validate_login(username, password):
    res = app.db.query(
        "SELECT id FROM users "
        'WHERE username = "{0}" AND password = "{1}"'.format(username, hashlib.sha256(password).hexdigest())
    )
    if len(res) == 1:
        return True
    return False


@app.route("/")
def index():
    if "username" in session:
Example #2
0
__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():
                                actionres[reskey] = actionparam[reskey]