Пример #1
0
def create_app():

    app = Flask(__name__, template_folder='templates')
    app.config.from_object(config)
    wtf_tinymce.init_app(app)
    Bootstrap(app)

    @app.route('/', methods=['GET', 'POST'])
    def home():
        storage = Storage()
        all_items = storage.items

        if request.method == 'POST':
            form = BlogPostForm(request.form)
            if form.validate():
                model = BlogPostModel(form.data)
                all_items.append(model)
                storage.save()
                return redirect(url_for('home'))
            else:
                logger.error('Someone have submitted an incorrect form!')
        else:
            form = BlogPostForm()

        return render_template(
            'home.html',
            form=form,
            items=all_items,
        )

    return app
Пример #2
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)

    wtf_tinymce.init_app(app)

    if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
        from flask.ext.sslify import SSLify
        sslify = SSLify(app)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0')

    return app
Пример #3
0
def create_app(config_name):

    app = Flask(__name__)

    app.config.from_object(config[config_name])

    config[config_name].init_app(app)

    csrf.init_app(app)

    bootstrap.init_app(app)

    mail.init_app(app)

    moment.init_app(app)

    db.init_app(app)

    login_manager.init_app(app)

    wtf_tinymce.init_app(app)

    # attach routes and custom error pages here

    from main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .hrequests import hrequests as hrequests_blueprint
    app.register_blueprint(hrequests_blueprint, url_prefix='/hrequests')

    from .clients import clients as clients_blueprint
    app.register_blueprint(clients_blueprint, url_prefix='/clients')

    from .productareas import productareas as productareas_blueprint
    app.register_blueprint(productareas_blueprint, url_prefix='/productareas')

    from .admin import admin as admin_blueprint
    app.register_blueprint(admin_blueprint, url_prefix='/admin')

    from .projects import projects as projects_blueprint
    app.register_blueprint(projects_blueprint, url_prefix='/projects')

    @app.errorhandler(403)
    def forbidden(error):
        return render_template('errors/403.html', title='Forbidden'), 403

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template('errors/404.html', title='Page Not Found'), 404

    @app.errorhandler(500)
    def internal_server_error(error):
        return render_template('errors/500.html', title='Server Error'), 500


    return app
Пример #4
0
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(Config)

    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    wtf_tinymce.init_app(app)

    from flaskblog.users.routes import users
    from flaskblog.posts.routes import posts
    from flaskblog.main.routes import main
    from flaskblog.errors.handlers import errors
    app.register_blueprint(users)
    app.register_blueprint(posts)
    app.register_blueprint(main)
    app.register_blueprint(errors)

    return app
from forms import RegistrationForm
from forms import LoginForm
from dbhelper import DBHelper as DBHelper
from grammar import Grammar
from wtf_tinymce import wtf_tinymce
import ProWritingAidSDK
import uuid
import datetime
from bs4 import BeautifulSoup

DB = DBHelper()
PH = PasswordHelper()

app = Flask(__name__)
login_manager = LoginManager(app)
wtf_tinymce.init_app(app)
app.secret_key = 'flkjsdfF7348503N=[F-0O3I4URasdfa7U8D54ferP4]WEOIEUPWc45u8O48DHOEkiwerRIGOQ'

configuration = ProWritingAidSDK.Configuration()
configuration.host = 'https://api.prowritingaid.com'
configuration.api_key['licenseCode'] = 'A17D00BF-3DF2-40DA-AE0F-0B8172F2CB1C'


@app.route("/")
def home():
    return render_template("home.html", loginform=LoginForm())


@app.route("/account")
@login_required
def account():
Пример #6
0
def create_app():
    # login_manager = LoginManager()

    wtf_tinymce.init_app(app)
    register_blueprints(app)
    return app
Пример #7
0
def create_app(config_name):
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(app_config[config_name])
    app.config.from_pyfile('config.py')

    #Bootstrap(app)
    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)
    wtf_tinymce.init_app(app)

    login_manager.login_message = "Veuillez vous connecté"
    login_manager.login_view = "authentification.login"
    login_manager.login_message_category = 'danger'
    SimpleMDE(app)
    Markdown(app)
    migrate = Migrate(app, db)
    #md= Markdown(app, extensions=['fenced_code'])
    from app import models
    ''' 
    Utilisation des stucture Blueprint
    '''
    @app.errorhandler(403)
    def forbidden(error):
        return render_template('errors/403.html', title='Forbidden'), 403

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template('errors/404.html',
                               title='Page non trouvée'), 404

    @app.errorhandler(500)
    def internal_server_error(error):
        return render_template('errors/500.html', title='Erreur serveur'), 500

    #Autres pages
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    #Authetification de l'utilisateur sur la plateforme
    from .authentification import authentification as authentification_blueprint
    app.register_blueprint(authentification_blueprint)

    #Les pages du dashbord de l'l'adminnistrateur
    from .users import users as users_blueprint
    app.register_blueprint(users_blueprint)

    #Les pages du dashbord, les posts
    from .posts import posts as posts_blueprint
    app.register_blueprint(posts_blueprint)

    #Les pages du dashbord, les posts
    from .rubriques import rubriques as rubriques_blueprint
    app.register_blueprint(rubriques_blueprint)

    #Ajout de l'album photo
    from .album import album as album_blueprint
    app.register_blueprint(album_blueprint)

    #Ajout Le sondage
    from .encours import encours as encours_blueprint
    app.register_blueprint(encours_blueprint)

    #Ajout Le sondage
    from .sondage import sondage as sondage_blueprint
    app.register_blueprint(sondage_blueprint)

    return app