#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import Flask from flask.ext.mail import Mail from flask.ext.assets import Environment, Bundle from flask.ext.lastuser import LastUser from baseframe import baseframe, networkbar_js, networkbar_css import coaster.app # First, make an app and config it app = Flask(__name__, instance_relative_config=True) app.register_blueprint(baseframe) mail = Mail() lastuser = LastUser() # Second, setup assets assets = Environment(app) js = Bundle('js/libs/jquery-1.5.1.min.js', 'js/libs/jquery.textarea-expander.js', 'js/libs/tiny_mce/jquery.tinymce.js', 'js/libs/jquery.form.js', 'js/libs/jquery.oembed.js', networkbar_js, 'js/scripts.js', filters='jsmin', output='js/packed.js') css = Bundle(networkbar_css, 'css/screen.css',
import re from datetime import datetime from markdown import Markdown from flask import render_template, redirect, request, g, url_for, Markup, abort, flash from flask.ext.lastuser import LastUser from flask.ext.lastuser.sqlalchemy import UserManager from coaster.views import get_next_url, jsonp from app import app from models import * from forms import ProposalSpaceForm, SectionForm, ProposalForm, CommentForm, DeleteCommentForm, ConfirmDeleteForm from utils import makename lastuser = LastUser(app) lastuser.init_usermanager(UserManager(db, User)) #lastuser.external_resource('email', 'http://iddev.hasgeek.in:7000/api/1/email', 'GET') markdown = Markdown(safe_mode="escape").convert jsoncallback_re = re.compile(r'^[a-z$_][0-9a-z$_]*$', re.I) # --- Routes ------------------------------------------------------------------ @app.route('/') def index(): spaces = ProposalSpace.query.filter(ProposalSpace.status >= 1).filter(ProposalSpace.status <= 4).order_by('date').all() return render_template('index.html', spaces=spaces)
from flask import Flask, _app_ctx_stack from sqlite3 import dbapi2 as sqlite3 from flask_mail import Mail import logging logging.basicConfig(filename = "flaskr.log", level=logging.INFO) __all__=['app','init_db', 'get_db', 'close_db_connection', 'lastuser', 'mail'] app = Flask(__name__, instance_relative_config=True) app.config.from_object('config.DevelopmentConfig') mail = Mail(app) DebugToolbarExtension(app) db = SQLAlchemy(app) lastuser = LastUser() lastuser.init_app(app) def init_db(): """Creates the database tables.""" with app.app_context(): db = get_db() with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit() def get_db(): """Opens a new database connection if there is none yet for the current application context. """ top = _app_ctx_stack.top