Exemplo n.º 1
0
 def test_middlware_off_by_header(self):
     app = HTMLMinMiddleware(self.wsgi_app)
     status, headers, body = self.call_app(app, '200 OK', (
         ('Content-Type', 'text/html'),
         ('X-HTML-Min-Enable', 'False'),
     ), '    X    Y   ')
     self.assertEqual(body, '    X    Y   ')
Exemplo n.º 2
0
 def test_middlware_keep_header(self):
     app = HTMLMinMiddleware(self.wsgi_app, keep_header=True)
     status, headers, body = self.call_app(app, '200 OK', [
         ('Content-Type', 'text/html'),
         ('X-HTML-Min-Enable', 'False'),
     ], '    X    Y   ')
     self.assertTrue(any((h == 'X-HTML-Min-Enable' for h, v in headers)))
Exemplo n.º 3
0
 def test_middlware_off_by_default(self):
   app = HTMLMinMiddleware(self.wsgi_app, by_default=False)
   status, headers, body = self.call_app(
     app, '200 OK', (('Content-Type', 'text/html'),),
     '    X    Y   ')
   self.assertEqual(body, '    X    Y   ')
Exemplo n.º 4
0
 def test_middlware_minifier_options(self):
   app = HTMLMinMiddleware(self.wsgi_app, remove_comments=True)
   status, headers, body = self.call_app(
     app, '200 OK', (('Content-Type', 'text/html'),),
     '    X    Y   <!-- Z -->')
   self.assertEqual(body, ' X Y ')
Exemplo n.º 5
0
#application.register_blueprint(front)
#application.register_blueprint(api)

runserver = lambda host, port, app: run_simple(
    host, port, app, use_debugger=True, use_reloader=True)
if not os.environ.get('TESTING'):
    from gevent.pywsgi import WSGIServer
    run_server = lambda host, port, app: WSGIServer(
        (host, port), app).serve_forever()

#front.config['DATABASE_URI'] = 'sqlite:///test3.db'
#api.config['DATABASE_URI'] = 'sqlite:///test3.db'

#application = DispatcherMiddleware(front,{
#    '/api/v1':api
#})

application = get_app('app', blueprints=dict(api=api, front=front))

if __name__ == "__main__":
    application.wsgi_app = HTMLMinMiddleware(application.wsgi_app)

    @application.before_first_request
    def set_secret():
        application.config['SECRET_KEY'] = make_secret_key()

    port = int(os.environ.get('PORT') or 8000)
    args = ['', port, application]
    run_server(*args)