summaryrefslogtreecommitdiff
path: root/flask1.py
blob: eb9ff2805c3add2db842a8ebfe8fcc33a8eb4ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask
from flask import Flask, request, jsonify
from tfa import *

app = Flask(__name__)
store = customstore()

@app.route('/')
def hello_world():
  return """Hello, World!
This is an authentication server 
Available directories are:
/c to create a key
/a to authorise a key
/v to verify that a key is authorised

"""

@app.route('/c', methods=['GET'])
def create():
  return store.create()

@app.route('/a/<code>', methods=['GET'])
def authenticate(code):
  if store.authenticate(code):
    return "True"
  else:
    return "False"

@app.route('/v/<code>', methods=['GET'])
def verify(code):
  if store.check(code):
    return "True"
  else:
    return "False"  

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=5000, debug=True)