diff options
| author | hc <hc@email.ch> | 2024-11-20 12:51:33 +0800 |
|---|---|---|
| committer | hc <hc@email.ch> | 2024-11-20 12:51:33 +0800 |
| commit | 853b82126baa1e8e408a10f91053c52626ffad29 (patch) | |
| tree | 2fc1de9695810681ba654aab3c2a4867aacc1ac7 /flask1.py | |
| parent | b1f88b682624e85b4b743343dfaaeed113b69413 (diff) | |
working
Diffstat (limited to 'flask1.py')
| -rw-r--r-- | flask1.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/flask1.py b/flask1.py new file mode 100644 index 0000000..eb9ff28 --- /dev/null +++ b/flask1.py | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | from flask import Flask | ||
| 2 | from flask import Flask, request, jsonify | ||
| 3 | from tfa import * | ||
| 4 | |||
| 5 | app = Flask(__name__) | ||
| 6 | store = customstore() | ||
| 7 | |||
| 8 | @app.route('/') | ||
| 9 | def hello_world(): | ||
| 10 | return """Hello, World! | ||
| 11 | This is an authentication server | ||
| 12 | Available directories are: | ||
| 13 | /c to create a key | ||
| 14 | /a to authorise a key | ||
| 15 | /v to verify that a key is authorised | ||
| 16 | |||
| 17 | """ | ||
| 18 | |||
| 19 | @app.route('/c', methods=['GET']) | ||
| 20 | def create(): | ||
| 21 | return store.create() | ||
| 22 | |||
| 23 | @app.route('/a/<code>', methods=['GET']) | ||
| 24 | def authenticate(code): | ||
| 25 | if store.authenticate(code): | ||
| 26 | return "True" | ||
| 27 | else: | ||
| 28 | return "False" | ||
| 29 | |||
| 30 | @app.route('/v/<code>', methods=['GET']) | ||
| 31 | def verify(code): | ||
| 32 | if store.check(code): | ||
| 33 | return "True" | ||
| 34 | else: | ||
| 35 | return "False" | ||
| 36 | |||
| 37 | if __name__ == '__main__': | ||
| 38 | app.run(host='0.0.0.0', port=5000, debug=True) | ||
