Skip to content

Instantly share code, notes, and snippets.

@wasabi0522
Created October 9, 2011 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasabi0522/1273721 to your computer and use it in GitHub Desktop.
Save wasabi0522/1273721 to your computer and use it in GitHub Desktop.
flaskr/__init__.py
from flask import Flask, request, g, url_for
from flaskext.sqlalchemy import SQLAlchemy
import config
from flaskr.util.db import db
app = Flask(__name__)
app.config.from_object(config)
app.static_path = '/static'
db.init_app(app)
def url_for_other_page(page):
args = request.view_args.copy()
args['page'] = page
return url_for(request.endpoint, **args)
def datetimeformat(value, format='%H:%M / %d-%m-%Y'):
return value.strftime(format)
app.jinja_env.filters['datetimeformat'] = datetimeformat
app.jinja_env.globals['url_for_other_page'] = url_for_other_page
from flaskr.controller import general, user, entry, comment
# def create_app(config=None):
# app = Flask(__name__)
# if config:
# app.config.from_object(config)
# else:
# app.config.from_object(default_settings)
# app.static_path = '/static'
# db.init_app(app)
# app.jinja_env.filters['datetimeformat'] = datetimeformat
# app.jinja_env.globals['url_for_other_page'] = url_for_other_page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment