<s> from flask import Flask , url_for , json <EOL> from flask import request , jsonify <EOL> from functools import wraps <EOL> import time <EOL> import sys <EOL> import datetime <EOL> app = Flask ( __name__ ) <EOL> import logging <EOL> file_handler = logging . FileHandler ( '<STR_LIT>' ) <EOL> app . logger . addHandler ( file_handler ) <EOL> app . logger . setLevel ( logging . INFO ) <EOL> from utils import * <EOL> import redis <EOL> r = redis . Redis ( host = '<STR_LIT:localhost>' , port = <NUM_LIT> ) <EOL> r . set_response_callback ( '<STR_LIT>' , list ) <EOL> stock = sys . argv [ <NUM_LIT:1> ] <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:GET>' ] ) <EOL> def last_row ( ) : <EOL> timestamp = datetime . datetime . fromtimestamp ( time . time ( ) ) . strftime ( '<STR_LIT>' ) <EOL> app . logger . info ( '<STR_LIT>' + timestamp + '<STR_LIT>' + '<STR_LIT>' ) <EOL> row = get_range_row ( stock , - <NUM_LIT:1> , - <NUM_LIT:1> , r ) [ <NUM_LIT:0> ] <EOL> return jsonify ( { '<STR_LIT>' : stock , '<STR_LIT>' : row [ <NUM_LIT:0> ] , '<STR_LIT>' : row [ <NUM_LIT:1> ] , '<STR_LIT>' : row [ <NUM_LIT:2> ] , '<STR_LIT>' : row [ <NUM_LIT:3> ] } ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( debug = True , port = <NUM_LIT> ) </s>
