Пример #1
0
def make_application():
    from tg import MinimalApplicationConfigurator

    config = MinimalApplicationConfigurator()
    config.update_blueprint({'root_controller': RootController()})

    return config.make_wsgi_app()
Пример #2
0
 def setup_class(cls):
     config = MinimalApplicationConfigurator()
     config.update_blueprint({
         'root_controller': RootController(),
         'csrf.secret': 'MYSECRET',
     })
     config.register(CSRFConfigurationComponent)
     config.register(SessionConfigurationComponent)
     cls.wsgi_app = config.make_wsgi_app()
Пример #3
0
from wsgiref.simple_server import make_server
from tg import MinimalApplicationConfigurator
from tg import expose, TGController


# RootController of our web app, in charge of serving content for /
class RootController(TGController):
    @expose(content_type="text/plain")
    def index(self):
        return 'Hello World'


# Configure a new minimal application with our root controller.
config = MinimalApplicationConfigurator()
config.update_blueprint({
    'root_controller': RootController()
})

# Serve the newly configured web application.
print("Serving on port 8080...")
httpd = make_server('', 8080, config.make_wsgi_app())
httpd.serve_forever()
Пример #4
0
    @expose("json", content_type="application/json")
    def refresh(self):
        return database.update_all()

    @expose("json", content_type="application/json")
    def endpoints(self):
        result = dict()
        for endpoint_name in selectable.all:
            endpoint_details = selectable.all[endpoint_name]
            result[endpoint_name] = {
                'name': endpoint_name,
                'endpoint': "{}:{}/{}".format(HOST, str(PORT), endpoint_name),
                'description': endpoint_details['description']
            }
        return result

    @expose("json", content_type="application/json")
    def formats(self):
        return available_formats


# Configure a new minimal application with our root controller.
config = MinimalApplicationConfigurator()
config.update_blueprint({'root_controller': RootController()})

# Serve the newly configured web application.
print("Health hub serving on port {}...".format(str(PORT)))
httpd = make_server('', PORT, config.make_wsgi_app())
httpd.serve_forever()
Пример #5
0
config.register(SQLAlchemyConfigurationComponent)

config.update_blueprint({
    'model':
    Bunch(DBSession=DBSession, init_model=init_model),
    'root_controller':
    RootController(),
    'renderers': ['kajiki'],
    'helpers':
    webhelpers2,
    'serve_static':
    True,
    'paths': {
        'static_files':
        'public'  # can now access any static files in public directory e.g. http://localhost:8080/styles.css
    },
    'use_sqlalchemy':
    True,
    'sqlalchemy.url':
    'sqlite:///devdata.db'  # equivalent of url in SQLAlchemy tutourial in base.py
})

application = config.make_wsgi_app()

# serve
from wsgiref.simple_server import make_server

print("Serving on port 8080...")
httpd = make_server('', 8080, application)
httpd.serve_forever()
Пример #6
0
                w.set_input(app_cfg['lg']['ps4'])
            elif cmd == "lg_power_on":
                send_magic_packet(app_cfg['lg']['mac'])
            elif cmd == "lg_power_off":
                w.power_off()
            else:
                return '{"response":"invalid_cmd"}'

            return '{"response":"ok"}'

        else:
            return '{"response":"invalid_cmd"}'


config = MinimalApplicationConfigurator()
config.register(StaticsConfigurationComponent)
config.update_blueprint({
    'root_controller': RootController(),
    'serve_static': True,
    'paths': {
        'static_files': 'static'
    }
})
config.register(SessionConfigurationComponent)
config.serve_static = True
#config.paths['static_files'] = 'static'
stream = open('config.yml', 'r')
app_cfg = yaml.load(stream)['c10tv']
print('Serving on port ' + str(app_cfg['port']) + '...')
httpd = make_server('', app_cfg['port'], config.make_wsgi_app())
httpd.serve_forever()
Пример #7
0
                consumer_key=rar_config['consumer_key'],
                redirect_uri=rar_config['redirect_uri'])
        except Exception as e:
            return '<h1 style="color: red">' + str(e)
        session['request_token'] = request_token
        session.save()
        try:
            auth_url = Pocket.get_auth_url(
                code=request_token, redirect_uri=rar_config['redirect_uri'])
        except Exception as e:
            return '<h1 style="color: red">' + str(e)

        print("REQUEST_TOKEN= %s" % (request_token))

        return writeJSRedir(auth_url)

    @expose(content_type='text/html')
    def logout(self):
        session.delete()
        return writeJSRedir('/index')


config = MinimalApplicationConfigurator()
config.update_blueprint({'root_controller': RootController()})
config.register(SessionConfigurationComponent)
stream = open('config.yml', 'r')
rar_config = yaml.load(stream, Loader=yaml.SafeLoader)['rar_config']
print(('Serving on port ' + str(rar_config['port']) + '...'))
httpd = make_server('', rar_config['port'], config.make_wsgi_app())
httpd.serve_forever()