예제 #1
0
def run():
    global userconfig
    global httpd
    config = AppConfig(minimal=True, root_controller=RootController())
    config['helpers'] = webhelpers2
    config.renderers = ['kajiki']
    config.serve_static = True
    config.paths['static_files'] = 'web/public'
    application = config.make_wsgi_app()

    print("Serving on port " + userconfig['Web']['porttoserve'] + "...")
    httpd = make_server('', int(userconfig['Web']['porttoserve']), application, 3)
    httpd.serve_forever()
예제 #2
0
def run_api():
    global userconfig
    try:
        port = userconfig['Web']['apiport']
    except KeyError:
        port = '9380'
    global httpd
    config = AppConfig(minimal=True, root_controller=APIRootController())
    config['helpers'] = webhelpers2
    config.renderers = ['kajiki']
    config.serve_static = False
    application = config.make_wsgi_app()

    print("Serving APIs on port " + port + "...")
    httpd = make_server('', int(port), application, 3)
    httpd.serve_forever()
예제 #3
0
def run():
    global userconfig
    try:
        port = userconfig['Web']['porttoserve']
    except AttributeError:
        port = '9375'
    global httpd
    config = AppConfig(minimal=True, root_controller=RootController())
    config['helpers'] = webhelpers2
    config.renderers = ['kajiki']
    config.serve_static = True
    config.paths['static_files'] = 'web/public'
    application = config.make_wsgi_app()

    print("Serving on port " + port + "...")
    httpd = make_server('', int(port), application, 3)
    httpd.serve_forever()
예제 #4
0
def start_server():
    """ start webserver """

    catalog_engine = create_engine(SQLITE_DATA_TARGET)
    login_engine = create_engine(LOGIN_DATA_TARGET)
    config = AppConfig(minimal=True,
                       root_controller=RootController(catalog_engine,
                                                      login_engine))
    config.sa_auth.charset = 'utf-8'
    config.renderers = ['kajiki']
    config.default_renderer = 'kajiki'
    config.serve_static = True
    config.paths['static_files'] = 'public'
    config.paths['controllers'] = 'controllers'

    application = config.make_wsgi_app()
    print "Serving on port 8080..."
    httpd = make_server('', 8080, application)
    httpd.serve_forever()
예제 #5
0
        output += "  <input type=\"submit\" value=\"Submit\">"
        output += " </form> "

        return output

    @expose()
    def conteiner(self, numero=None):
        DBSession.add(Conteiner(numero=numero or ''))
        DBSession.commit()
        return "OK"


config = AppConfig(minimal=True, root_controller=RootController())

config.renderers = ['kajiki']
config.serve_static = True
config.paths['static_files'] = 'img'
config['use_sqlalchemy'] = True
config['sqlalchemy.url'] = 'sqlite:///devdata.db'
from tg.util import Bunch
from sqlalchemy.orm import scoped_session, sessionmaker

DBSession = scoped_session(sessionmaker(autoflush=True, autocommit=False))


def init_model(engine):
    DBSession.configure(bind=engine)
    DeclarativeBase.metadata.create_all(
        engine)  # Create tables if they do not exist

예제 #6
0
from tg import expose, TGController, AppConfig

class RootController(TGController):
     @expose()
     def index(self):
         return "<h1>Hello World</h1>"

class RootController(TGController):
    @expose()
    def index(self):
        return 'Hello World'

    @expose('hello.jinja')
    def hello(self, person=None):
        return dict(person=person)

config = AppConfig(minimal=True, root_controller=RootController())
config.renderers = ['jinja']
config.serve_static = True
config.paths['static_files'] = 'public'

import webhelpers2
import webhelpers2.text
config['helpers'] = webhelpers2

application = config.make_wsgi_app()

print "Serving on port 80..."
httpd = make_server('', 80, application)
httpd.serve_forever()