diff options
author | Kyle Kaminski <kyle.kaminski@trustwave.com> | 2022-08-22 17:47:21 -0500 |
---|---|---|
committer | Kyle Kaminski <kyle.kaminski@trustwave.com> | 2022-08-22 17:47:21 -0500 |
commit | c61fb13cb391bb79dd16a15e937b3e5ceb167a27 (patch) | |
tree | ca4d4b04f37b7758f92a4732d34c07520287037f | |
parent | bc48463d44bc4e113304ff030c172ad858702bbb (diff) | |
download | PythonPractice-c61fb13cb391bb79dd16a15e937b3e5ceb167a27.tar.gz PythonPractice-c61fb13cb391bb79dd16a15e937b3e5ceb167a27.tar.bz2 PythonPractice-c61fb13cb391bb79dd16a15e937b3e5ceb167a27.zip |
mmm decorators
-rw-r--r-- | flask-without-decorator.py | 9 | ||||
-rw-r--r-- | scratch.py | 16 |
2 files changed, 24 insertions, 1 deletions
diff --git a/flask-without-decorator.py b/flask-without-decorator.py new file mode 100644 index 0000000..a63a989 --- /dev/null +++ b/flask-without-decorator.py @@ -0,0 +1,9 @@ +from flask import Flask +app = Flask(__name__) + +def say_hello(): + return "hello, world!" +app.add_url_rule("/hello", "sayhello", say_hello) # 1st param: URL pathname, 2nd: flask's internal name of endpoint, 3rd: func to call to reply + +if __name__ == '__main__': + app.run()
\ No newline at end of file @@ -1,4 +1,5 @@ import sys +import time class Baz: def hello(self): @@ -9,4 +10,17 @@ if True: print("hello, {0}".format('world!')) c = Baz() -c.hello()
\ No newline at end of file +c.hello() + + + +success = False +retry = 3 +while not success and retry > 0: + try: + #raise Exception('my') + success = True + except Exception as e: + print(e, file=sys.stderr) + time.sleep(1) + retry = retry - 1
\ No newline at end of file |