Skip to content

Commit 6e0b1a8

Browse files
authored
Added app1 implementation
1 parent 63ed034 commit 6e0b1a8

37 files changed

Lines changed: 2381 additions & 0 deletions

web/flask/app1/404.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Page Not Found</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<style>
8+
9+
* {
10+
line-height: 1.2;
11+
margin: 0;
12+
}
13+
14+
html {
15+
color: #888;
16+
display: table;
17+
font-family: sans-serif;
18+
height: 100%;
19+
text-align: center;
20+
width: 100%;
21+
}
22+
23+
body {
24+
display: table-cell;
25+
vertical-align: middle;
26+
margin: 2em auto;
27+
}
28+
29+
h1 {
30+
color: #555;
31+
font-size: 2em;
32+
font-weight: 400;
33+
}
34+
35+
p {
36+
margin: 0 auto;
37+
width: 280px;
38+
}
39+
40+
@media only screen and (max-width: 280px) {
41+
42+
body, p {
43+
width: 95%;
44+
}
45+
46+
h1 {
47+
font-size: 1.5em;
48+
margin: 0 0 0.3em;
49+
}
50+
51+
}
52+
53+
</style>
54+
</head>
55+
<body>
56+
<h1>Page Not Found</h1>
57+
<p>Sorry, but the page you were trying to view does not exist.</p>
58+
</body>
59+
</html>
60+
<!-- IE needs 512+ bytes: https://blogs.msdn.microsoft.com/ieinternals/2010/08/18/friendly-http-error-pages/ -->

web/flask/app1/LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) HTML5 Boilerplate
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

web/flask/app1/app.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
from flask import Flask, render_template, request, jsonify
2+
app = Flask(__name__, static_url_path='/static')
3+
4+
#starting data
5+
#design and programmed by fullarray and Jonathan H.
6+
teams = [
7+
{
8+
'id': 1,
9+
'title': u'Dolphins',
10+
'description': u'Football team in Miami, FL',
11+
'done': False
12+
},
13+
{
14+
'id': 2,
15+
'title': u'Browns',
16+
'description': u'Football team in Cleveland, OH',
17+
'done': False
18+
},
19+
{
20+
'id': 3,
21+
'title': u'Patriots',
22+
'description': u'Football team in Foxborough, NE',
23+
'done': False
24+
}
25+
]
26+
27+
teamlist = ['Bucs','Dolphins', 'Bills', 'Patriots', 'Seahawks', '49ers', 'Falcons', 'Browns', 'Rams', 'Titans']
28+
29+
@app.route('/')
30+
def index():
31+
sport_type = "NFL football"
32+
return render_template('index.html', sport=sport_type)
33+
34+
#design and programmed by fullarray and Jonathan H.
35+
@app.route('/send', methods=['GET', 'POST'])
36+
def send():
37+
if request.method == 'POST':
38+
teamname = request.form['teamname']
39+
if teamname.lower() not in [x.lower() for x in teamlist]:
40+
errormsg = 'Your team does not exists.'
41+
#design and programmed by fullarray and Jonathan H.
42+
return render_template('index.html', errormsg=errormsg)
43+
44+
team = [team for team in teams if team['title'] == teamname.capitalize()]
45+
#design and programmed by fullarray and Jonathan H.
46+
if len(team) == 0:
47+
team = {
48+
'id': teams[-1]['id'] + 1,
49+
'title': teamname.capitalize(),
50+
'description': "awesome",
51+
'done': False
52+
}
53+
teams.append(team)
54+
return render_template('team.html', teamname=teamname.upper(), teamlistnow=teams)
55+
return render_template('index.html')
56+
57+
58+
#api
59+
@app.route('/football/api/v1.0/teams/', methods=['GET'])
60+
def get_all_teams():
61+
return jsonify({'teams': teams})
62+
63+
64+
@app.route('/football/api/v1.0/teams/<int:team_id>', methods=['GET'])
65+
def get_teams(team_id):
66+
team = [team for team in teams if team['id'] == team_id]
67+
#design and programmed by fullarray and Jonathan H.
68+
if len(team) == 0:
69+
abort(404)
70+
return jsonify({'teams': team[0]})
71+
72+
@app.route('/football/api/v1.0/teams', methods=['POST'])
73+
def create_team():
74+
if not request.json or not 'title' in request.json:
75+
abort(400)
76+
team = {
77+
'id': teams[-1]['id'] + 1,
78+
'title': request.json['title'],
79+
'description': request.json.get('description', ""),
80+
'done': False
81+
}
82+
teams.append(team)
83+
return jsonify({'team': team}), 201
84+
85+
if __name__ == "__main__":
86+
app.run()

web/flask/app1/browserconfig.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Please read: https://msdn.microsoft.com/en-us/library/ie/dn455106.aspx -->
3+
<browserconfig>
4+
<msapplication>
5+
<tile>
6+
<square70x70logo src="tile.png"/>
7+
<square150x150logo src="tile.png"/>
8+
<wide310x150logo src="tile-wide.png"/>
9+
<square310x310logo src="tile.png"/>
10+
</tile>
11+
</msapplication>
12+
</browserconfig>

0 commit comments

Comments
 (0)