Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
25 changes: 25 additions & 0 deletions Lizhang_Xie/Flask/Counter/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from flask import Flask, render_template,session,redirect
app = Flask(__name__)
app.secret_key = "Welp"

@app.route('/')
def index():
if 'count' not in session:
session['count'] = 0

session['count'] += 1
return render_template('index.html',count=session['count'])

@app.route('/twice')
def twice():
session['count'] +=1
return redirect('/')

@app.route('/reset')
def reset():
session['count'] = 0
return redirect('/')

if __name__ == '__main__':
app.run(debug=True)

15 changes: 15 additions & 0 deletions Lizhang_Xie/Flask/Counter/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>index</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link href="css/style.css" rel="stylesheet">-->
</head>
<body>
<h1>Counter</h1>
<p>{{count}}times.</p>
<button><a href="/twice">+2 button</a></button>
<button><a href="/reset">reset</a></button>
</body>
</html>
28 changes: 28 additions & 0 deletions Lizhang_Xie/Flask/DisappearingNinja/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flask import Flask, request, render_template,redirect
app = Flask(__name__)

@app.route('/')
def hello():
return 'No ninjas here'

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

@app.route('/ninja/<color>')
def show_color(color):
if color == "blue":
location = "img/leonardo.jpg"
elif color == "orange":
location = "../static/img/michelangelo.jpg"
elif color == "red":
location = "../static/img/raphael.jpg"
elif color == "purple":
location = "../static/img/donatello.jpg"
else:
location = "../static/img/notapril.jpg"
return render_template('display_color.html', url = location)


if __name__ == '__main__':
app.run(debug=True)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Lizhang_Xie/Flask/DisappearingNinja/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
img{
width: 200px;
}
14 changes: 14 additions & 0 deletions Lizhang_Xie/Flask/DisappearingNinja/templates/display_color.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Display Color</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<!--<img src="{{url}}" alt="">-->
<img src="{{ url_for('static',filename=url) }}" alt="">

</body>
</html>
15 changes: 15 additions & 0 deletions Lizhang_Xie/Flask/DisappearingNinja/templates/ninja.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>ninja</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<img src="{{ url_for('static',filename='img/donatello.jpg')}}" alt="">
<img src="{{ url_for('static',filename='img/leonardo.jpg')}}" alt="">
<img src="{{ url_for('static',filename='img/michelangelo.jpg')}}" alt="">
<img src="{{ url_for('static',filename='img/raphael.jpg')}}" alt="">
</body>
</html>
18 changes: 18 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask import Flask, request, render_template, redirect

app = Flask(__name__)

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

@app.route('/result', methods=["POST"])
def result():
print "Got the info."
name = request.form["name"]
location = request.form['location']
language = request.form['language']
comment = request.form['comment']
return render_template('result.html', name = name, location = location, language = language, comment = comment)

app.run(debug=True)
6 changes: 6 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div{
width: 300px;
border: 3px solid black;
padding: 20px;
margin: 100px;
}
29 changes: 29 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>index</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<div>
<form action="/result" id="main_form" method="post">
Your Name: <input type="text" name="name" value="">
<p></p>
Dojo Location: <select name="location" form="main_form">
<option value="Dallas">Dallas</option>
<option value="Seattle">Seattle</option>
</select>
<p></p>
Favorite Language: <select name="language" form="main_form">
<option value="Python">Python</option>
<option value="C++">C++</option>
</select>
<p>Comment(optional):</p>
<textarea name="comment" cols="30" rows="10"></textarea>
<input type="submit" name="submit" value="submit">
</form>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey/templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>result</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<div>
<h2>Submitted info</h2>
<p>Name: {{name}}</p>
<p>Location: {{location}}</p>
<p>Language: {{language}}</p>
<p>Comment: {{comment}}</p>
<button><a href="/">BACK</a></button>
<a href="/"><button>GO Back</button></a>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey_validation/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from flask import Flask, request, render_template, redirect,flash, session

app = Flask(__name__)
app.secret_key = "asdfd"


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

@app.route('/result', methods=["POST"])
def result():
print "Got the info."
if len(request.form["name"]) < 1:
flash("Name cannot be empty!")
return redirect('/')
else:
flash("Success! Your name is {}".format(request.form['name']))
name = request.form["name"]
location = request.form['location']
language = request.form['language']

if len(request.form["comment"]) < 1:
flash("Comment cannot be empty!")
return redirect('/')
elif len(request.form["comment"]) > 120:
flash("Comment cannot be more than 120 characters!")
return redirect('/')
else:
flash("Success!")
comment = request.form['comment']
return render_template('result.html', name = name, location = location, language = language, comment = comment)

app.run(debug=True)
10 changes: 10 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey_validation/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
div{
width: 300px;
border: 3px solid black;
padding: 20px;
margin: 100px;
}

#red{
color: red;
}
37 changes: 37 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey_validation/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>index</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<div>
<h5>Enter a Valid(Any) Name, Comment(within 120 characters)!</h5>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<p id="red">{{message}}</p>
{% endfor %}
{% endif %}
{% endwith %}
<form action="/result" id="main_form" method="post">
Your Name: <input type="text" name="name" value="">
<p></p>
Dojo Location: <select name="location" form="main_form">
<option value="Dallas">Dallas</option>
<option value="Seattle">Seattle</option>
</select>
<p></p>
Favorite Language: <select name="language" form="main_form">
<option value="Python">Python</option>
<option value="C++">C++</option>
</select>
<p>Comment(optional):</p>
<textarea name="comment" cols="30" rows="10"></textarea>
<input type="submit" name="submit" value="submit">
</form>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions Lizhang_Xie/Flask/DojoSurvey_validation/templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>result</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../static/style.css" rel="stylesheet">
</head>
<body>
<div>
<h2>Submitted info</h2>
<p>Name: {{name}}</p>
<p>Location: {{location}}</p>
<p>Language: {{language}}</p>
<p>Comment: {{comment}}</p>
<button><a href="/">BACK</a></button>
<a href="/"><button>GO Back</button></a>
</div>
</body>
</html>
51 changes: 51 additions & 0 deletions Lizhang_Xie/Flask/GreaterNumberGame/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from flask import Flask, render_template, redirect,request,session
import random
app = Flask(__name__)
app.secret_key = "keysssss"


@app.route('/')
def index():
# session.pop('random')
# session.pop('status')
# session.pop('guess')
if 'random' not in session:
session['random'] = random.randrange(0,101)
if 'status' not in session:
session['status'] = 'new'
print session['random']
return render_template('index.html')

@app.route('/random', methods=['POST'])
def random_num():
session['guess'] = int(request.form['guess'])
print session['guess']
print session['random']
if session['guess'] == session['random']:
return redirect('/correct')
else:
return redirect('/wrong')

@app.route('/wrong')
def wrong():
if session['guess'] < session['random']:
session['status'] = "low"
elif session['guess'] > session['random']:
session['status'] = "high"
return redirect('/')

@app.route('/correct')
def corret():
session['status'] = "correct"
return redirect('/')

@app.route('/reset')
def reset():
session['random'] = random.randrange(0,101)
session.pop('guess')
session['status'] = 'new'
return redirect('/')

if __name__ == '__main__':
app.run(debug=True)

20 changes: 20 additions & 0 deletions Lizhang_Xie/Flask/GreaterNumberGame/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

div {
padding-top: 50px;
width: 200px;
height: 150px;
background-color: red;
color: white;
font-size: 18pt;
border: 2px solid black;
margin-bottom: 20px;
}
div p{
text-align: center;
}
button{
margin-left: 50px;
}
#box {
background-color: green;
}
Loading