def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' user = utilities.get_my_user() if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_main( self, utilities.get_logout_url(self), user, utilities.get_anagrams_of_user(utilities.get_my_user())) else: renderer.render_login(self, utilities.get_login_url(self))
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' # get user data object from datastore of current user (logged in) my_user = utilities.get_my_user() button = self.request.get('button') file = self.request.get('file') # openFile = open(file) # readLine = openFile.readline() out = [] buff = [] with open(file, 'r') as file: dictionaryWord = "%s" % (file.read()) for c in dictionaryWord: if c == '\n': out.append(''.join(buff)) buff = [] else: buff.append(c) else: if buff: out.append(''.join(buff)) print(out) for i in out: dictionaryWord = i lowercaseWord = dictionaryWord input_text = utilities.prepare_text_input(lowercaseWord) logging.debug(input_text) logging.debug(button) if button == 'Upload': self.add(input_text, my_user) self.redirect('/addanagram')
def get(self): self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) result, wordCount, totalCount = utilities.get_anagrams_of_user( utilities.get_my_user()) renderer.render_main(self, utilities.get_logout_url(self), result, wordCount, totalCount) else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_searchtext( self, utilities.get_logout_url(self), utilities.generate_id(self.request.get('value')), utilities.prepare_text_input(self.request.get('value')), utilities.get_anagrams_of_user(utilities.get_my_user())) else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): # if myuser object is None --> No user with key found --> new user --> make new user in datastore if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_subanagram( self, utilities.get_logout_url(self), self.request.get('name'), utilities.get_anagrams_of_user(utilities.get_my_user())) # if no user is logged in create login url else: renderer.render_login(self, utilities.get_login_url(self))
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' my_user = utilities.get_my_user() button = self.request.get('button') input_text = utilities.prepare_text_input(self.request.get('value')) logging.debug(input_text) logging.debug(button) if button == 'Add': self.add(input_text, my_user) self.redirect('/') elif button == 'Delete': anagram_id = my_user.key.id() + '/' + str(self.request.get('anagram_id')) self.delete(my_user, anagram_id) self.redirect('/')
def post(self): self.response.headers['Content-Type'] = 'text/html' my_user = utilities.get_my_user() button = self.request.get('button') input_text = utilities.prepare_text_input(self.request.get('value')) file = self.request.get('uploadFile') if button == 'Upload': openFile = open(file) readLine = openFile.readline() while readLine: word = (readLine.strip('\n\r')).lower() permutations = utilities.all_permutations(word) wordsinfo = utilities.filter_english_words(permutations) anagram_id = my_user.key.id() + '/' + utilities.generate_id( word) anagram_key = ndb.Key(Anagram, anagram_id) anagrams = anagram_key.get() if anagrams: utilities.add_to_anagram(word, wordsinfo, anagram_key) else: utilities.add_new_anagram(my_user, word, wordsinfo, anagram_id, anagram_key) readLine = openFile.readline() openFile.close() self.redirect('/') if button == 'Search': search_result = self.search(input_text, my_user) renderer.render_search(self, input_text, search_result) elif button == 'Generate': words = self.generate(input_text, my_user) renderer.render_search(self, input_text, words)
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' # get user data object from datastore of current user (logged in) my_user = utilities.get_my_user() button = self.request.get('button') input_text = utilities.prepare_text_input(self.request.get('value')) logging.debug(input_text) logging.debug(button) if button == 'Add': self.add(input_text, my_user) self.redirect('/') elif button == 'Search': search_result = self.search(input_text, my_user) renderer.render_search(self, False, input_text, search_result) elif button == 'Show': number = self.request.get('number') if utilities.number_is_valid(number): result = self.number_search(number, my_user) renderer.render_search(self, True, number, result) else: self.redirect('/') elif button == 'Delete': anagram_id = my_user.key.id() + '/' + str( self.request.get('anagram_id')) self.delete(my_user, anagram_id) self.redirect('/') elif button == 'Generate': words = self.generate(input_text) renderer.render_search(self, False, input_text, words)