Example #1
0
 def configure_routes():
     """
     This will register API routes
     :return:
     """
     logger.info("Configuring API routes")
     app.register_blueprint(persuasion_engine)
Example #2
0
#!/usr/bin/env python
# coding=utf8
"""
create on 2017-10-11
@author: cao kun
"""

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from settings import app
from index.views import index_app
from test_demo.model import *
from project.model import *
from auth.model import *
from order.model import *

app.register_blueprint(index_app)

migrate = Migrate(app, db)
manage = Manager(app)
manage.add_command('db', MigrateCommand)

# @manage.command
# def create_db():
#     db.create_all()

if __name__ == '__main__':
    # app.run(host='0.0.0.0', port=9999, debug=app.debug)
    manage.run()
Example #3
0
# Vert studios website. Yay!

from settings import FLASK_ENV, app
from flask import (
 request, g, abort, flash, redirect, 
 render_template, url_for
)
from contact.contact import contact_page
from blog.blog import blog
from blog.helpers import from_the_blog
from jinja2 import TemplateNotFound

app.register_blueprint(contact_page)
app.register_blueprint(blog)

#####################################################################
# Routes
#####################################################################

@app.route('/')
def home():
  # Get HTML for the home page rss feed
  rssFeed = from_the_blog()
  return render_template("index.html", rssFeed=rssFeed)

@app.route('/work')
def work():
  return render_template("work.html", title="Work")

@app.route('/services')
def services():
Example #4
0
from flask import Flask, render_template
from settings import app, socketio

#Blueprints
from task.views import task_blueprint
from websocket.views import websocket_blueprint

app.register_blueprint(task_blueprint)
app.register_blueprint(websocket_blueprint)


@app.route('/')
def index():
    return render_template('index.html')


if __name__ == "__main__":
    socketio.run(app, debug=True)
Example #5
0
import os

from flask import send_from_directory, g, url_for, render_template
from flask_login import current_user

from settings import app, static_dir
from index.views import index_app
from test_demo.views import test_app
from project.views import project_app
from auth.views import auth_app
from order.views import order_app
from wechat.views import wechat_app
from frontend.index.views import frontend_app

app.register_blueprint(index_app, url_prefix='/admin')
app.register_blueprint(test_app, url_prefix='/test')
app.register_blueprint(project_app, url_prefix='/admin/project')
app.register_blueprint(auth_app, url_prefix='/auth')
app.register_blueprint(order_app, url_prefix='/admin/order')
app.register_blueprint(wechat_app, url_prefix='/admin/wechat')

app.register_blueprint(frontend_app)


@app.before_request
def before_request():
    g.user = current_user


@app.errorhandler(404)
def register_blueprints(app):
    from Controllers.controller import posts_controller
    app.register_blueprint(posts_controller)
Example #7
0
        currency = ""

        if item.currency_specified:
            currency = item.currency_specified
        else:
            country = CountryCurrency.query.filter(
                CountryCurrency.country == item.country).first()
            if country:
                currency = country.currency

        if currency:
            item.eprice = item.eprice * currency_rate.caculate_rate(
                currency, 'TWD')

    return render_template('eprice.html',
                           items=sorted(items,
                                        key=lambda d: d.eprice,
                                        reverse=False),
                           game_name=game_name)


@app.teardown_request
def shutdown_session(exception=None):
    db.session.remove()


from linebot_apis import line_bot_api_blueprint
app.register_blueprint(line_bot_api_blueprint)

if __name__ == "__main__":
    app.run()
Example #8
0
import sys
import time
from multiprocessing import Process
from datetime import datetime
from flask import render_template

sys.path.insert(
    0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '.'))

from auth import auth_bp
from admin import admin_bp, fetch_instances_cost_from_aws
from user_blueprint import user_bp
from settings import app, db

# Registaring blueprints
app.register_blueprint(auth_bp)
app.register_blueprint(admin_bp)
app.register_blueprint(user_bp)


@app.route('/')
def index():
    return render_template('login.html')


def fetch_bill_from_aws(duration=86400):
    while True:
        fetch_instances_cost_from_aws()
        delay = duration + int(time.time() / duration) * duration - time.time()
        print("Going to sleep for %s seconds" % delay)
        time.sleep(delay)
Example #9
0
from flask import Blueprint
from flask_restful import Api
from settings import app, db
from .models import News

news_bp = Blueprint('news_app', __name__)
api = Api(news_bp)
app.register_blueprint(news_bp, url_prefix='/news')

from .routes import *
    print(namelist)
    return namelist


# print(jsonify(User.get_all_users_names()))
# allNames = jsonify(User.get_all_users_names())
# listOfNames = []
# for name in allNames:
#     oneName = allNames[name]
#     print(oneName)
#     listOfNames.append(oneName)
# print(listOfNames)

# return jsonify(User.get_all_users_names())
"""
Error Handling 
~~~~~~~~~~~~~~
"""


@bp.errorhandler(404)
def page_not_found(error):
    flash(error)
    return render_template('404.html'), 404


app.register_blueprint(bp)

if __name__ == '__main__':
    app.run(port=80, debug=True)
Example #11
0
from flask import Blueprint
from flask_restful import Api
from settings import app, db
from .models import User, Role
from flask_jwt_extended import JWTManager
from flask_security import SQLAlchemyUserDatastore, Security

users_bp = Blueprint('users', __name__)
api = Api(users_bp)
app.register_blueprint(users_bp, url_prefix='/user')

jwt = JWTManager(app)

user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(app, user_datastore)


@app.before_first_request
def before_first_request():
    # Create the Roles
    user_datastore.find_or_create_role(
        name='admin', description='Have access to admin panel')
    user_datastore.find_or_create_role(name='editor',
                                       description='Can edit database')
    user_datastore.find_or_create_role(name='mobile user',
                                       description='Standard mobile user')

    db.session.commit()

    if not User.query.filter_by(login='******').first():
        user_datastore.create_user(login='******',
Example #12
0
from flask import Blueprint
from flask_restful import Api
from settings import app

cases_bp = Blueprint('shop', __name__)
api = Api(cases_bp)
app.register_blueprint(cases_bp, url_prefix='/shop')

from flask_jwt_extended import JWTManager
jwt = JWTManager(app)

from .routes import *