#๐Ÿ”’ In flask in a metho how do I redirect sometimes to one route and other times another route?

5 messages ยท Page 1 of 1 (latest)

mighty shuttle
#

I have a method the problem is sometimes I want to redirect to 1 route and sometimes I want to redirect to another different route.
How do I accomplish this ?

    def wait_max_thirty_min_for_new_token(self): 
        '''
        Wait a max of 30 min before getting the last emailed token.
        This only happens when creating the last token. 
        Else redirect to the registration_verification_code route.
        '''
        time_token_expired_db = self.time_token_expired 
        # executes at 9:00 <= 9:30pm
        current_time = datetime.now()
        if self and self.attempts_token_tried >= 5 and current_time <= time_token_expired_db:
            # only works duringb pytest
            print('wait_max_thirty_min_for_new_token, success')
            # create times for the created token + expired token
            # better wording.lf
            flash('You have requested to many tokens. Please wait 30 minutes for a new token from when you recieved your last token.')
            return redirect(url_for('email_login_confirmation.registration_verification_code', username_db=self.username))
        else:
            # is this secure?
            return None
orchid ridgeBOT
#

@mighty shuttle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

mighty shuttle
#

In flask in a metho how do I redirect sometimes to one route and other times another route?

orchid ridgeBOT
#

@mighty shuttle

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.