# -*- coding: utf-8 -*- import os from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from sina import Sina from sina.config import DEFAULT_CONFIG from vilya import api, frontend from vilya.middleware import GitDispatcher frontend_app = frontend.create_app() api_app = api.create_app() PROJECT_ROOT = api_app.config['REPO_PATH'] DEFAULT_CONFIG['project_root'] = PROJECT_ROOT DEFAULT_CONFIG['chunked'] = True sina_app = Sina(DEFAULT_CONFIG) @sina_app.get_repo_path def get_repo_path_handler(environ, path): with api_app.app_context(): from vilya.services import users, projects user = users.get_by_name_path(path) if user: print user.name project = projects.get_by_name_path(path) return os.path.join(PROJECT_ROOT, project.path) @sina_app.has_permission
def _create_app(self, settings): return create_app(settings)
# -*- coding: utf-8 -*- from flask.ext.script import Manager from vilya.api import create_app from vilya.manage import CreateUserCommand, DeleteUserCommand, ListUsersCommand manager = Manager(create_app()) manager.add_command('create_user', CreateUserCommand()) manager.add_command('delete_user', DeleteUserCommand()) manager.add_command('list_users', ListUsersCommand()) if __name__ == "__main__": manager.run()
# -*- coding: utf-8 -*- from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from vilya import api, frontend application = DispatcherMiddleware(frontend.create_app(), { '/api': api.create_app() }) if __name__ == "__main__": run_simple('0.0.0.0', 5000, application, use_reloader=True, use_debugger=True)
# -*- coding: utf-8 -*- from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from vilya import frontend, api from vilya.middleware import DispatcherMiddleware as GitDispatcherMiddleware frontend_app = frontend.create_app() frontend_app.wsgi_app = GitDispatcherMiddleware(frontend_app) application = frontend_app vilya_app = DispatcherMiddleware(frontend_app, {"/api": api.create_app()}) if __name__ == "__main__": run_simple("localhost", 5000, vilya_app, use_reloader=True, use_debugger=True)
from __future__ import with_statement import sys from os.path import dirname, abspath sys.path.append(dirname(dirname(abspath(__file__)))) from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig from vilya.models import * from vilya.core import db from vilya.api import create_app app = create_app() # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. def run_migrations_offline():