-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
31 lines (27 loc) · 1000 Bytes
/
app.py
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
from flask import Flask, request, jsonify
from vulcan import Account, Keystore, Vulcan
import json
import asyncio
app = Flask(__name__)
@app.route('/register')
async def main():
try:
token = request.args.get('token')
pin = request.args.get('pin')
keystore = Keystore.create(device_model="Elektron Discord")
account = await Account.register(keystore, token, "zielonagora", pin)
client = Vulcan(keystore, account)
await client.select_student()
student = client.student
if "zielonagora-001250" in student.symbol_code:
name = student.pupil.first_name + " " + student.pupil.last_name
klasa = student.class_
return jsonify(
name=name,
klasa=klasa
)
else: raise Exception('Nie chodzisz do elektrona')
except Exception as e:
return jsonify(error=repr(e))
if __name__ == "__main__":
app.run(host='127.0.0.1', port=5555, debug=False)