#NEWLINE# @ blueprint . route ( '/run_code' , methods = [ 'POST' ] ) #NEWLINE# @ api_wrapper #NEWLINE# @ require_login #NEWLINE# @ require_team #NEWLINE# @ block_before_competition ( "You can't solve problems before the competition starts!" ) #NEWLINE# def programming_run_code_hook( ) : #NEWLINE# #INDENT# db = api . common . db_conn ( ) #NEWLINE# user = api . user . get_user ( ) #NEWLINE# team = api . team . get_team ( ) #NEWLINE# pid = request . form . get ( 'pid' ) #NEWLINE# program = request . form . get ( 'program' ) #NEWLINE# if ( ( pid is None ) or ( len ( program ) < 1 ) ) : #NEWLINE# #INDENT# raise WebException ( 'Please submit a program!' ) #NEWLINE# #UNINDENT# language = request . form . get ( 'language' ) #NEWLINE# token = ( 'prog_' + api . common . token ( ) ) #NEWLINE# ticket = { #NEWLINE# #INDENT# 'uid' : user [ 'uid' ] , #NEWLINE# 'tid' : team [ 'tid' ] , #NEWLINE# 'pid' : pid , #NEWLINE# 'token' : token , #NEWLINE# 'timestamp' : datetime . now ( ) . timestamp ( ) , #NEWLINE# 'language' : language , #NEWLINE# 'program' : program , #NEWLINE# 'done' : False , #NEWLINE# 'claimed' : 0 , #NEWLINE# #UNINDENT# } #NEWLINE# db . programs . insert_one ( ticket ) #NEWLINE# return { #NEWLINE# #INDENT# 'success' : 1 , #NEWLINE# 'message' : 'Started execution! Check below for results.' , #NEWLINE# #UNINDENT# }