-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathowstatistics-app.py
52 lines (42 loc) · 1.14 KB
/
owstatistics-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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
# -*- coding: utf-8 -*-
from flask import Flask, jsonify
import json
import sys
sys.path.append('./src/')
import infojugador
app = Flask(__name__)
@app.route('/')
@app.route('/status')
def inicio():
p=infojugador.InfoJugador()
status=p.status()
if status == 'OK':
with open('status.json') as f:
salida = json.load(f)
return jsonify(salida)
@app.route('/player/<battletag>')
def info(battletag):
p=infojugador.InfoJugador()
perfil=p.isPerfilPublico(battletag)
nivel=p.getNivel(battletag)
if perfil == False:
perfil = 'Privado'
return jsonify(perfil=perfil, nivel=nivel)
else:
top5=p.getTop5(battletag)
return jsonify(perfil=perfil, nivel=nivel, top5_personajes=top5)
@app.route('/player/<battletag>/top5')
def showTop5(battletag):
p=infojugador.InfoJugador()
perfil=p.isPerfilPublico(battletag)
if perfil != False:
top5=p.getTop5(battletag)
return jsonify(top5_personajes=top5)
else:
return 'Este perfil es privado, no se pude obtener información'
@app.errorhandler(404)
def page_not_found(error):
return 'Error HTTP 404, Not Found'
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)