I am new to Python, Mod_WSGI and Bottle. My main problem is that when the process starts using Mod_WSGI, I want it to download the file once during initialization. When running a terminal script, you simply useif __name__ == '__main__'
I need to download the file once during initialization (or the first call) so that any subsequent calls to the process do not require a file reload. I am not sure how to do this.
The following code runs whenever someone goes to the recommendations page
@route('/recommend')
def recommend():
parser = OptionParser(usage="usage: %prog [options]")
parser.add_option('-f', '--file', default='data.csv', help='Specify csv file to read item data from.')
parser.add_option('-D', '--debug', action='store_true', dest='debug', help='Put bottle in debug mode.')
(options, args) = parser.parse_args()
return res.recommend(request)
How do I make the first 4 lines (those that contain the parser) only during initialization, so I just need to call res.recommend () whenever the recommendations page is available?
,