<s> import web <EOL> from pymongo . connection import Connection <EOL> from pymongo import ASCENDING , DESCENDING <EOL> import settings <EOL> urls = ( <EOL> '<STR_LIT>' , '<STR_LIT:index>' <EOL> ) <EOL> def get_mongo_collection ( db , collection , host , port ) : <EOL> return Connection ( host , port ) [ db ] [ collection ] <EOL> app = web . application ( urls , globals ( ) ) <EOL> render = web . template . render ( '<STR_LIT>' , base = '<STR_LIT>' ) <EOL> db = get_mongo_collection ( ** settings . MONGO ) <EOL> class index : <EOL> def GET ( self , level ) : <EOL> args = { } <EOL> if level and level in [ '<STR_LIT:info>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:error>' , '<STR_LIT>' ] : <EOL> args = { '<STR_LIT>' : level } <EOL> def fill_missing ( el ) : <EOL> if not '<STR_LIT:host>' in el : <EOL> el [ '<STR_LIT:host>' ] = '<STR_LIT>' <EOL> return el <EOL> logs = map ( fill_missing , db . find ( args , limit = <NUM_LIT:100> ) . sort ( '<STR_LIT>' , DESCENDING ) ) <EOL> return render . index ( logs ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
