Example #1
0
    def validate_password(form, field):
        if len(field.data) < 4:
            raise ValidationError("The password is too short")


"""
    Application Setup
    ~~~~~~~~~
"""

app = Flask(__name__)
app.debug = True
app.config["CONTENT_DIR"] = os.path.abspath("content")
app.config["TITLE"] = "wiki"
app.config["MARKUP"] = "markdown"  # default markup for editing new pages
app.config["SORT"] = "title"
app.config["THEME"] = "elegant"  # more at waliki/static/codemirror/theme
try:
    app.config.from_pyfile(os.path.join(app.config.get("CONTENT_DIR"), "config.py"))
except IOError:
    print("Startup Failure: You need to place a " "config.py in your content directory.")

CACHE_DIR = os.path.join(app.config.get("CONTENT_DIR"), "cache")
cache.init_app(app, config={"CACHE_TYPE": "filesystem", "CACHE_DIR": CACHE_DIR})
manager = Manager(app)

loginmanager = LoginManager()
loginmanager.init_app(app)
loginmanager.login_view = "user_login"
markup = dict([(klass.NAME, klass) for klass in Markup.__subclasses__()])[app.config.get("MARKUP")]
Example #2
0
File: app.py Project: phryk/waliki
    def validate_password(form, field):
        if len(field.data) < 4:
            raise ValidationError("The password is too short")


"""
    Application Setup
    ~~~~~~~~~
"""

app = Flask(__name__)
app.debug = True
app.config["CONTENT_DIR"] = os.path.abspath("content")
app.config["TITLE"] = "wiki"
app.config["MARKUP"] = "markdown"  # or 'restructucturedtext'
app.config["THEME"] = "elegant"  # more at waliki/static/codemirror/theme
try:
    app.config.from_pyfile(os.path.join(app.config.get("CONTENT_DIR"), "config.py"))
except IOError:
    print("Startup Failure: You need to place a " "config.py in your content directory.")

CACHE_DIR = os.path.join(app.config.get("CONTENT_DIR"), "cache")
cache.init_app(app, config={"CACHE_TYPE": "filesystem", "CACHE_DIR": CACHE_DIR})
manager = Manager(app)

loginmanager = LoginManager()
loginmanager.init_app(app)
loginmanager.login_view = "user_login"
markup = dict([(klass.NAME, klass) for klass in Markup.__subclasses__()])[app.config.get("MARKUP")]