<s> import os <EOL> from werkzeug . wrappers import Request , Response <EOL> from werkzeug . exceptions import HTTPException <EOL> from werkzeug . wsgi import SharedDataMiddleware <EOL> from werkzeug . routing import Rule <EOL> from werkzeug . serving import run_simple <EOL> import kaylee <EOL> from kaylee . contrib . frontends . werkzeug_frontend import make_url_map <EOL> from kaylee . util import setup_logging <EOL> import logging <EOL> log = logging . getLogger ( __name__ ) <EOL> url_map = make_url_map ( url_prefix = '<STR_LIT>' ) <EOL> @ Request . application <EOL> def application ( request ) : <EOL> adapter = url_map . bind_to_environ ( request . environ ) <EOL> try : <EOL> endpoint , values = adapter . match ( ) <EOL> return endpoint ( request , ** values ) <EOL> except HTTPException as e : <EOL> return e <EOL> def run ( settings_file , static_dir , port = <NUM_LIT> , debug = False ) : <EOL> loglevel = logging . DEBUG if debug else logging . INFO <EOL> setup_logging ( loglevel ) <EOL> kaylee . setup ( settings_file ) <EOL> with open ( os . path . join ( static_dir , '<STR_LIT>' ) ) as f : <EOL> index_data = f . read ( ) <EOL> def _home ( request ) : <EOL> return Response ( index_data , mimetype = '<STR_LIT>' ) <EOL> home_rule = Rule ( '<STR_LIT:/>' , methods = [ '<STR_LIT:GET>' ] , endpoint = _home ) <EOL> url_map . add ( home_rule ) <EOL> log . debug ( static_dir ) <EOL> app = SharedDataMiddleware ( application , <EOL> { '<STR_LIT>' : static_dir } ) <EOL> run_simple ( '<STR_LIT:127.0.0.1>' , port , app , use_debugger = True , <EOL> use_reloader = False ) </s>
