def run_werkzeug(app, host='127.0.0.1', port=8000, thread=0, proc=1): from werkzeug import script action_runserver = None if thread > 0: action_runserver = script.make_runserver(lambda: app, hostname=host, port=port, threaded=thread) else: action_runserver = script.make_runserver(lambda: app, hostname=host, port=port, processes=proc) log.info("Server running on port %s:%d" % (host, port)) action_shell = script.make_shell(lambda: {}) script.run(args=['runserver'])
def __init__(self, application): self.application = application self._actions = { 'cherrypy' : run_cherrypy_server(application), 'runcgi' : runcgi(application), 'shell' : script.make_shell(lambda: {"app": application}), 'runserver' : script.make_runserver(lambda: application, use_reloader=True, threaded=True, hostname='localhost', port=7777, use_debugger=True), }
#!/usr/bin/env python import os from werkzeug import script from werkzeug.wsgi import SharedDataMiddleware def make_app(): from web_app.application import App app = SharedDataMiddleware( App(), { '/static': os.path.join(os.path.dirname(__file__), 'web_app/static'), }) return app def make_shell(): from web_app import utils application = make_app() return locals() action_runserver = script.make_runserver(make_app, hostname='0.0.0.0', port=7777, use_reloader=False) action_shell = script.make_shell(make_shell) if __name__ == '__main__': script.run()
#!/usr/bin/env python from naya.script import make_shell from werkzeug.script import make_runserver, run from modular import app action_shell = make_shell(lambda: {'app': app}) action_run = make_runserver( lambda: app, use_reloader=True, use_debugger=True ) if __name__ == '__main__': run()
#!/usr/bin/env python import os import tempfile from werkzeug import script def make_app(): from shorty.application import Shorty filename = os.path.join(tempfile.gettempdir(), "shorty.db") return Shorty('sqlite:///{0}'.format(filename)) def make_shell(): from shorty import models, utils application = make_app() return locals() action_runserver = script.make_runserver(make_app, use_reloader=True) action_shell = script.make_shell(make_shell) action_initdb = lambda: make_app().init_database() script.run()
app = Wurstgulasch(database_uri=Configuration().database_uri) app.__call__ = SharedDataMiddleware( app.__call__, { '/assets': './assets', '/static': './static' } ) #app.__call__ = CacheMiddleware(app.__call__) app.__call__ = SessionMiddleware(app.__call__, type='dbm', data_dir='./sessions') return app def shell_init(conf_file_location='wurstgulasch.cfg'): Configuration().load_from_file(conf_file_location) import model return { 'wurstgulasch': Wurstgulasch(database_uri=Configuration().database_uri), 'model': model } if __name__ == "__main__": from werkzeug.serving import run_simple from werkzeug import script action_runserver = script.make_runserver(create_app, use_debugger=True, use_reloader=True) action_initdb = lambda: create_app().init_database() action_shell = script.make_shell(shell_init) script.run()
from lodgeit import local from lodgeit.application import make_app from lodgeit.database import db dburi = 'sqlite:////tmp/lodgeit.db' SECRET_KEY = 'no secret key' def run_app(app, path='/'): env = create_environ(path, SECRET_KEY) return run_wsgi_app(app, env) action_runserver = script.make_runserver( lambda: make_app(dburi, SECRET_KEY, debug=True), use_reloader=True) action_shell = script.make_shell( lambda: { 'app': make_app(dburi, SECRET_KEY, False, True), 'local': local, 'db': db, 'run_app': run_app }, ('\nWelcome to the interactive shell environment of LodgeIt!\n' '\n' 'You can use the following predefined objects: app, local, db.\n' 'To run the application (creates a request) use *run_app*.') )
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Manage web.py like application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A small example application that is built after the web.py tutorial. We even use regular expression based dispatching. The original code can be found on the `webpy.org webpage`__ in the tutorial section. __ http://webpy.org/tutorial2.en :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), "webpylike")) from example import app from werkzeug import script action_runserver = script.make_runserver(lambda: app) action_shell = script.make_shell(lambda: {}) if __name__ == "__main__": script.run()
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Manage i18nurls ~~~~~~~~~~~~~~~ Manage the i18n url example application. :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import os from i18nurls import make_app from werkzeug import script action_runserver = script.make_runserver(make_app) action_shell = script.make_shell(lambda: {}) if __name__ == '__main__': script.run()
def main(): action_runserver = script.make_runserver(make_app, use_reloader=True) script.run()
return redirect('/pycwb/') else: raise NotFound(request.path) def make_app(): return DispatcherMiddleware(redirect_to_pycwb, { '/pycwb': application}) def make_debugged(): return DebuggedApplication(make_app()) static_dirs={ '/static':os.path.join(os.path.dirname(__file__),'static') } action_runserver = script.make_runserver(make_app,static_files=static_dirs) action_rundebugging = script.make_runserver(make_debugged,static_files=static_dirs) def action_add_user(username='******',passwd=''): create_user(username,passwd) def action_archive_user(username='******'): archive_user(username) def action_add_annotator(dbname='xxx', taskname='task1', username=''): add_annotator(dbname, taskname, username) def action_remove_task(dbname='xxx', taskname='task1'): get_corpus(dbname).remove_task(taskname)
#!/usr/bin/env python from werkzeug import script from webscard.config import Config CONFIG_FILE = 'webscard.cfg' config = Config(CONFIG_FILE) def make_app(): from webscard.application import WebSCard return WebSCard(config) def make_shell(): application = make_app() return locals() action_runserver = script.make_runserver( make_app, hostname=config.gethost(), port=config.getport(), use_reloader=True, extra_files=CONFIG_FILE, use_debugger=True) action_initdb = lambda: make_app().init_database() action_shell = script.make_shell(make_shell) script.run()
:license: BSD, see LICENSE for more details. """ import os from werkzeug import script def make_app(): """Helper function that creates a plnt app.""" from plnt import Plnt database_uri = os.environ.get('PLNT_DATABASE_URI') app = Plnt(database_uri or 'sqlite:////tmp/plnt.db') app.bind_to_context() return app action_runserver = script.make_runserver(make_app, use_reloader=True) action_shell = script.make_shell(lambda: {'app': make_app()}) def action_initdb(): """Initialize the database""" from plnt.database import Blog, session make_app().init_database() # and now fill in some python blogs everybody should read (shamelessly # added my own blog too) blogs = [ Blog('Armin Ronacher', 'http://lucumr.pocoo.org/', 'http://lucumr.pocoo.org/cogitations/feed/'), Blog('Georg Brandl', 'http://pyside.blogspot.com/', 'http://pyside.blogspot.com/feeds/posts/default'), Blog('Ian Bicking', 'http://blog.ianbicking.org/',
def run_app(app, path='/'): config = config_generate() env = create_environ(path, config["secret_key"]) return run_wsgi_app(app, env) def action_runfcgi(): from flup.server.fcgi import WSGIServer workpath = dirname(argv[0]) config = config_generate() application = make_app(config) bindaddr = pathjoin(workpath, "werkzeug.sock") print "Binding to %s" % (bindaddr,) WSGIServer(application, bindAddress=bindaddr).run() action_runserver = script.make_runserver( lambda: make_app(config_generate(), debug=True), use_reloader=True) action_shell = script.make_shell( lambda: { 'app': make_app(config_generate(), False, True), 'local': local, 'db': db, 'run_app': run_app, }, ('\nWelcome to the interactive shell environment of LodgeIt!\n' '\n' 'You can use the following predefined objects: app, local, db.\n' 'To run the application (creates a request) use *run_app*.') )
from lodgeit.application import make_app from lodgeit.database import db import os import binascii dburi = 'mysql://*****:*****@db:3306/enzotools_pastebin' % \ os.environ["DB_ENV_MYSQL_ROOT_PASSWORD"] SECRET_KEY = binascii.hexlify(os.urandom(24)) def run_app(app, path='/'): env = create_environ(path, SECRET_KEY) return run_wsgi_app(app, env) action_runserver = script.make_runserver( lambda: make_app(dburi, SECRET_KEY, debug=True), use_reloader=True) action_shell = script.make_shell( lambda: { 'app': make_app(dburi, SECRET_KEY, False, True), 'local': local, 'db': db, 'run_app': run_app }, ('\nWelcome to the interactive shell environment of LodgeIt!\n' '\n' 'You can use the following predefined objects: app, local, db.\n' 'To run the application (creates a request) use *run_app*.')) if __name__ == '__main__': script.run()
#!env/bin/python import os, getpass from werkzeug import script from getpass import getpass from web import app def load_app(): return app def make_shell(): return {'app': app} action_runserver = script.make_runserver(load_app, use_reloader=True, threaded=True) action_shell = script.make_shell(make_shell) script.run()
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # from werkzeug import script def make_couchit(): from couchit.application import CouchitApp return CouchitApp() def shell_init_func(): from couchit import settings couchit = make_couchit() return locals() def setup(): from couchit.utils import install install() action_runserver = script.make_runserver(make_couchit, use_reloader=True) action_shell = script.make_shell(shell_init_func) action_setup = setup if __name__ == '__main__': script.run()
from mozugs.app import BugTrackerApp static = {"/static": os.path.join(root, "static")} config_dir = os.path.join(root, "config") config_files = [os.path.join(config_dir, fn) for fn in os.listdir(config_dir) if fn.endswith(".ini")] def _create_app(): app = BugTrackerApp(root, [os.path.join(config_dir, "test.ini"), os.path.join(config_dir, "local.ini")]) models.ModelBase.metadata.create_all(app.engine) return app def _init_shell(): return {"app": _create_app()} action_run = script.make_runserver( _create_app, port=1111, use_reloader=True, extra_files=config_files, static_files=static ) action_shell = script.make_shell(_init_shell) def action_gensalt(): print(security.gen_salt(8)) if __name__ == "__main__": script.run(globals())
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Manage web.py like application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A small example application that is built after the web.py tutorial. We even use regular expression based dispatching. The original code can be found on the `webpy.org webpage`__ in the tutorial section. __ http://webpy.org/tutorial2.en :copyright: 2007 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), 'webpylike')) from example import app from werkzeug import script action_runserver = script.make_runserver(lambda: app) action_shell = script.make_shell(lambda: {}) if __name__ == '__main__': script.run()
store.find(models.Directory, models.Directory.user_id==user.id).remove() store.find(models.Pipeline, models.Pipeline.user_id==user.id).remove() store.remove(user) try: store.flush() except: store.rollback() else: store.commit() from werkzeug import script import wsgiref.handlers script.run(dict( runserver = script.make_runserver(lambda: application, use_reloader=True, threaded=True, hostname='localhost', port=7777, use_debugger=True), shell = script.make_shell(lambda: {"app": application}), runcgi = lambda: wsgiref.handlers.CGIHandler().run(application), cherrypy = run_cherrypy_server, runfcgi = run_fcgi, runscgi = run_scgi, create_auth_tables = create_auth_tables, drop_auth_tables = drop_auth_tables, dbshell = db_shell, show_tables = show_tables, show_create = show_create, clear = clear, clear_data = clear_data, drop_user = drop_user, create_super_user = create_super_user,
WSGIServer(application, "/", bindAddress=(hostname, port), debug=True).run() def show_tables(): models.tsdb.showTables() def show_create(): models.tsdb.showCreate() def db_shell(): models.tsdb.runDBShell() from werkzeug import script import wsgiref.handlers script.run( dict( runserver=script.make_runserver( lambda: application, hostname="0.0.0.0", use_reloader=True, threaded=True, port=8888, use_debugger=True ), shell=script.make_shell(lambda: {"app": application}), runcgi=lambda: wsgiref.handlers.CGIHandler().run(application), cherrypy=run_cherrypy_server, runfcgi=run_fcgi, runscgi=run_scgi, dbshell=db_shell, show_tables=show_tables, show_create=show_create, ), "", )
#!/usr/bin/python import os import sys import blikit from blikit.application import Blikit, is_git_repo from werkzeug import script from werkzeug.contrib import profiler if not is_git_repo('.'): print >> sys.stderr, 'not a git repository' sys.exit(0) def make_app(): return Blikit('.') action_runserver = script.make_runserver(make_app) action_develop = script.make_runserver(make_app, use_reloader=True, use_debugger=True) action_profile = profiler.make_action(make_app, stream=open('/tmp/profiler.log', 'w')) script.run()
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Manage i18nurls ~~~~~~~~~~~~~~~ Manage the i18n url example application. :copyright: 2007 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import os from i18nurls import make_app from werkzeug import script action_runserver = script.make_runserver(make_app) action_shell = script.make_shell(lambda: {}) if __name__ == '__main__': script.run()
from werkzeug import script def __make_app(): from gluttonee import app return app def __make_shell(): app = __make_app() ctx = app.test_request_context() ctx.push() app.preprocess_request() import flask return locals() def __map_app(): app = __make_app() print "Routing Map: \n"+str(app.url_map) action_map = __map_app action_serve = script.make_runserver(__make_app, use_reloader=True, use_debugger=True) action_console = script.make_shell(__make_shell) script.run()