Skip to content

Commit

Permalink
all modules ready
Browse files Browse the repository at this point in the history
  • Loading branch information
obedjunias19 committed Nov 17, 2019
1 parent f453e45 commit bdc9146
Show file tree
Hide file tree
Showing 7,885 changed files with 1,423,345 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLASK_APP=main.py
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.pythonPath": "f:\\Python-SS\\venv\\Scripts\\python.exe",
"workbench.colorCustomizations": {
"activityBar.background": "#143410",
"titleBar.activeBackground": "#1B4916",
"titleBar.activeForeground": "#F6FCF5"
}
}
Binary file added __pycache__/main.cpython-37.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from flask import Flask

app = Flask(__name__)

from app import routes
Binary file added app/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added app/__pycache__/routes.cpython-37.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions app/data/TestRanks.xslx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pos Team Matches Points Rating
1 India 39 4659 119
2 New Zealand 26 2829 109
3 England 42 4366 104
4 South Africa 31 3177 102
5 Australia 33 3270 99
6 Sri Lanka 40 3795 95
7 Pakistan 27 2263 84
8 West Indies 32 2570 80
9 Bangladesh 23 1413 61
10 Afghanistan 3 165 55
11 Zimbabwe 9 140 16
12 Ireland 3 0 0


21 changes: 21 additions & 0 deletions app/data/scraper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from urllib import request
from bs4 import BeautifulSoup
import pandas as pd
import re

def getTestRanks(url):
link = url
html_page = request.urlopen(link);
soup = BeautifulSoup(html_page,'lxml')
table = soup.find_all('table',class_="StoryengineTable")
data = table[0].get_text()
#Rough cleaning to store as an excel file
clean_data = re.sub('(\\n)',',',data)
clean_data = re.sub('(,,,,|,,,|,,)',' \n ',clean_data)
clean_data = re.sub(',',' \t ',clean_data)
with open('TestRanks.xslx','w') as f:
f.write(clean_data)
print("Successfully got the data.")

url = "http://www.espncricinfo.com/rankings/content/page/211271.html"
getTestRanks(url)
38 changes: 38 additions & 0 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from app import app
from flask import render_template
import pandas as pd
from pandas_highcharts.core import serialize

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

@app.route("/dashboard")
def dashboard():
return(render_template("dashboard.html"))

@app.route("/test/rankings")
def test_rankings():
df1 = pd.read_csv("app\data\TestRanks.xslx",sep="\t")
df1.dropna(inplace=True)
table1 = df1.to_html(header=False,index=False,border=0)
with open("app/templates/testrankings.html","r") as ht1:
ht11 = ht1.read()
return(ht11+table1+
''' </div>
</section>
</body>
</html>''')

@app.route('/test/graph')
def graph(chartID = 'chart_ID', chart_type = 'column', chart_height = 500):
df1 = pd.read_csv("app/data/TestRanks.xslx",sep="\t")
df1.dropna(inplace=True)
df2 = df1[[' Points ',' Team ']]
df2.set_axis(df2[' Team '],axis=0,inplace=True)
chart = serialize(df2, render_to='my-chart', output_type='json',kind="bar",title=" ICC Test Rankings")
return render_template('graph1.html', chart=chart)



Loading

0 comments on commit bdc9146

Please sign in to comment.