示例#1
0
文件: api.py 项目: JoneXiong/MoCrud
def setup(app_models):
    for attr in dir(app_models):
        m=app_models.__getattribute__(attr)
        inherit_flag = False
        if hasattr(m,'__bases__'):
            if len(m.__bases__)>0:
                m_base = m.__bases__[0]
                if m_base.__name__ in ('CrudModel','BaseModel','Model'):
                    inherit_flag = True
                else:
                    if len(m_base.__bases__)>0:
                        if m_base.__bases__[0].__name__ in ('CrudModel','BaseModel','Model'):
                            inherit_flag = True
            
        if inherit_flag  and m.__name__ not in ['Model','CrudModel','BaseModel']:
            m_admin = None
            if hasattr(m,"Admin"):
                if issubclass(m.Admin, ModelAdmin):
                    m_admin = m.Admin
            if m_admin==None:
                m.Admin = m_admin = ModelAdmin
                admin.register('default',m)
            else:
                admin.register('default',m,m_admin)
    admin.setup()
示例#2
0
from app import app
from auth import auth
# from flask import Blueprint, abort, request, Response, session, redirect, url_for, g
from peewee import IntegrityError

from admin import admin
from api import api
from views import *

admin.setup()
api.setup()

if __name__ == '__main__':
    auth.User.create_table(fail_silently=True)
    # Note.create_table(fail_silently=True)
    try:
        admin = auth.User(username='******', email='', admin=True, active=True)
        admin.set_password('admin')
        admin.save()
    except IntegrityError:
        print "User 'admin' already created!"

    app.debug = True
    app.run(host='0.0.0.0', port=8008)
示例#3
0
"""
this is the "secret sauce" -- a single entry-point that resolves the
import dependencies.  If you're using blueprints, you can import your
blueprints here too.

then when you want to run your app, you point to main.py or `main.app`
"""
from app import db
from app import app as application

from auth import *
from admin import admin
# from api import api
from models import *
from views import *
from scripts import setup

admin.setup()
# api.setup()

IM_DIR = 'images/'
SEC_DIR = 'secondary/'

setup.initialize(IM_DIR, SEC_DIR)

if __name__ == '__main__':
    app.run(port=8080)