
from contextlib import closing
from sqlite3 import connect
from bottle import template, route, run

@route('/virustotal/<db>')
def virus(db):
    with connect(db, timeout=10) as connection:
        with closing(connection.cursor()) as cursor:
            cursor.execute('SELECT detected, count(*) FROM virus GROUP BY detected ORDER BY detected')
            return template('virustotal', title=db, cursor=cursor, refresh=10)

run(host='0.0.0.0')



from contextlib import closing
from sqlite3 import connect
from bottle import request, template, route, run

@route('/virustotal/<db>')
def virus(db):
    with connect(db, timeout=10) as connection:
        with closing(connection.cursor()) as cursor:
            cursor.execute('SELECT detected, count(*) FROM virus GROUP BY detected ORDER BY detected')
            return template('virustotal', title=db, cursor=cursor, refresh=request.query.refresh)

run(host='0.0.0.0')


Use refresh only if required in parameters (?refresh=something)
Use refresh only if required in parameters (?refresh=something)

  
  from contextlib import closing
  from sqlite3 import connect
- from bottle import template, route, run
+ from bottle import request, template, route, run
  
  @route('/virustotal/<db>')
  def virus(db):
      with connect(db, timeout=10) as connection:
          with closing(connection.cursor()) as cursor:
              cursor.execute('SELECT detected, count(*) FROM virus GROUP BY detected ORDER BY detected')
-             return template('virustotal', title=db, cursor=cursor, refresh=10)
+             return template('virustotal', title=db, cursor=cursor, refresh=request.query.refresh)
  
  run(host='0.0.0.0')
  
  
Use refresh only if required in parameters (?refresh=something)
## Code Before:

from contextlib import closing
from sqlite3 import connect
from bottle import template, route, run

@route('/virustotal/<db>')
def virus(db):
    with connect(db, timeout=10) as connection:
        with closing(connection.cursor()) as cursor:
            cursor.execute('SELECT detected, count(*) FROM virus GROUP BY detected ORDER BY detected')
            return template('virustotal', title=db, cursor=cursor, refresh=10)

run(host='0.0.0.0')


## Instruction:
Use refresh only if required in parameters (?refresh=something)
## Code After:

from contextlib import closing
from sqlite3 import connect
from bottle import request, template, route, run

@route('/virustotal/<db>')
def virus(db):
    with connect(db, timeout=10) as connection:
        with closing(connection.cursor()) as cursor:
            cursor.execute('SELECT detected, count(*) FROM virus GROUP BY detected ORDER BY detected')
            return template('virustotal', title=db, cursor=cursor, refresh=request.query.refresh)

run(host='0.0.0.0')

