<s> """<STR_LIT>""" <EOL> import os <EOL> import six <EOL> try : <EOL> import conf <EOL> except ImportError : <EOL> conf = None <EOL> def get ( attr , default ) : <EOL> result = os . getenv ( '<STR_LIT>' + attr . upper ( ) ) <EOL> if result is None : <EOL> result = getattr ( conf , attr , None ) <EOL> if result is None : <EOL> result = default <EOL> return result <EOL> docfiles_dir = get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> docfiles_link_root = get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> copyright = get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> title = get ( '<STR_LIT:title>' , '<STR_LIT>' ) <EOL> welcome = get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> intro = get ( '<STR_LIT>' , """<STR_LIT>""" ) <EOL> host = get ( '<STR_LIT:host>' , '<STR_LIT:127.0.0.1>' ) <EOL> port = int ( get ( '<STR_LIT:port>' , <NUM_LIT> ) ) <EOL> debug = bool ( get ( '<STR_LIT>' , None ) ) <EOL> readonly = get ( '<STR_LIT>' , False ) <EOL> max_content_mb = float ( get ( '<STR_LIT>' , <NUM_LIT:8> ) ) <EOL> renderables = dict ( ( k , v ) for ( k , v ) in globals ( ) . items ( ) if isinstance ( v , six . string_types ) ) <EOL> def serve_gevent ( app ) : <EOL> from gevent . wsgi import WSGIServer <EOL> http_server = WSGIServer ( ( host , port ) , app ) <EOL> http_server . serve_forever ( ) <EOL> def serve_flask ( app ) : <EOL> app . run ( host , port , debug ) <EOL> def calc_serve ( serve_from_conf , gevent_module , debug_from_conf , wsgi_server_from_conf ) : <EOL> if serve_from_conf is not None : <EOL> return serve_from_conf <EOL> if debug_from_conf : <EOL> default_wsgi = '<STR_LIT>' <EOL> elif gevent_module is not None : <EOL> default_wsgi = '<STR_LIT>' <EOL> else : <EOL> default_wsgi = '<STR_LIT>' <EOL> wsgi_server = wsgi_server_from_conf or default_wsgi <EOL> servefunc = { <EOL> '<STR_LIT>' : serve_gevent , <EOL> '<STR_LIT>' : serve_flask } [ wsgi_server ] <EOL> return servefunc <EOL> def _calc_serve ( ) : <EOL> try : <EOL> import gevent <EOL> except ImportError : <EOL> gevent = None <EOL> return calc_serve ( get ( '<STR_LIT>' , None ) , gevent , debug , get ( '<STR_LIT>' , None ) ) <EOL> serve = _calc_serve ( ) </s>
