<s> from flask import Flask , render_template , request , redirect <EOL> from Utilities import * <EOL> from Authentication import * <EOL> app = Flask ( __name__ ) <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> @ requires_auth <EOL> def index ( ) : <EOL> return render_template ( '<STR_LIT>' ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:POST>' , '<STR_LIT:GET>' ] ) <EOL> @ requires_auth <EOL> def search ( ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> keyword = request . form [ '<STR_LIT>' ] <EOL> else : <EOL> keyword = "<STR_LIT>" <EOL> epubs = get_epubs ( epub_directory_path , keyword = keyword ) <EOL> epubs . sort ( ) <EOL> result = [ { '<STR_LIT>' : create_link ( epub ) , '<STR_LIT:name>' : epub } for epub in epubs ] <EOL> return render_template ( '<STR_LIT>' , keyword = keyword , results = group_results ( result ) ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:GET>' ] ) <EOL> @ requires_auth <EOL> def get_ebook ( name ) : <EOL> real_name = base64_to_str ( name ) <EOL> return redirect ( convert_ebook ( real_name ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
