def make_database():
    db = dblib.get_connection()
    db.footballparser.remove()
    db.footballpermanent.remove()
    for name in ['Moussa Dembele', 'Marouane Fellaini', 'Romelu Lukaku', 'Simon Mignolet', 'Thomas Vermaelen', 'Jan Vertonghen']:
        db.footballparser.insert(set_calendar_stats(name))
        db.footballpermanent.insert(set_perm_scores(name))
Exemplo n.º 2
0
from flask import Flask, render_template
import os

import dblib
db = dblib.get_connection()

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/<player>')
def player_data(player):
    permanent_stats = db.footballpermanent.find({'name': player})[0]
    match_stats = [x for x in db.footballparser.find({'name': player})]
    last_match = [x for x in match_stats if x['url']!='n/a'][-1]
    next_match = [x for x in match_stats if x['url']=='n/a'][0]
    template_data = {
            'name' : player,
            'stats' : permanent_stats,
            'last_match' : last_match,
            'next_match' : next_match,
            }
    return render_template('template.html', **template_data)

if __name__ == '__main__':
    if 'MONGOLAB_URL' in os.environ:
        app.run()
    else:
        port_number = int(os.environ.get('PORT', 5000))