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
55 changes: 55 additions & 0 deletions stage1/Xiaoguang_Zhu/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/python3
from flask import Flask, render_template, url_for, request, redirect

SVIP = ['咸鱼', 'juju', 'dalao', '大腿', '油条', '萌新', 'other']

app = Flask(__name__)

####################### route ####################################

@app.route('/')
def index():
return render_template('index.html',
index_css = url_for('static', filename='css/index.css'))

@app.route('/step1')
def step1():
return '<title>CodeMonkey</title> <p>Hello World</p>'

@app.route('/step2')
def step2():
return render_template('step2.html',
step2_css = url_for('static', filename='css/step2.css'),
image = url_for('static', filename='img/MetroLoadin.gif'),
js = url_for('static', filename='js/step2.js'))

@app.route('/step3', methods=['GET', 'POST'])
def step3_login():
user_title = request.args.get('title', '')
user_name = request.args.get('name', '')
print(user_title, user_name)
# a stupid way of solving the login issue
if user_title=='' and user_name=='':
return render_template('step3_index.html')
return redirect('/step3/%s/%s' % (user_title, user_name))

@app.route('/step3/<title>/<name>')
def step3_userpage(title, name):
something = '<p>'
for i in SVIP[0:6]:
if i == title:
something += '<font color="gold">%s </font>' % i
else:
something += '<font>%s </font>' % i
if title not in SVIP[0:6]:
something += '<font color="red">other</font>'
else:
something += '<font>other</font>'
something += '</p>'
return render_template('step3_userpage.html',
title = title, name = name, something = something)

#################################################################

if __name__ == '__main__':
app.run(debug=True)
5 changes: 5 additions & 0 deletions stage1/Xiaoguang_Zhu/static/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
h1
{
text-align: center;
color: blue;
}
6 changes: 6 additions & 0 deletions stage1/Xiaoguang_Zhu/static/css/step2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
h1
{
text-align: center;
font-family: monospace;
color: blue;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added stage1/Xiaoguang_Zhu/static/img/funny.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions stage1/Xiaoguang_Zhu/static/js/step2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function dont_touch_me()
{
alert("吔屎啦你!");
}

12 changes: 12 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{ index_css }}">
<title>Task 1</title>
</head>
<body>
<h1>Task 1 - Xiaoguang Zhu</h1>
<a href="/step1">/step1</a>
<a href="/step2">/step2</a>
<a href="/step3">/step3</a>
</body>
15 changes: 15 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/personal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html>
<title>
Personal Page
</title>

{% if name == 'smdsbz' %}
<h1> Hi, boss! </h1>
{% elif name == 'President Jiang' %}
<p> +1s </p>
{% elif name %}
<h1> Hi, {{ name }}! Long time no see! </h1>
{% else %}
<h1>I don't seem to know you, but hi anyway.</h1>
{% endif %}
22 changes: 22 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/step2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE HTML>

<html>
<head>
<title>
Hello World PULS
</title>
<link rel="stylesheet" type="text/css" href="{{ step2_css }}">
</head>

<body>
<h1>
Hello World!
</h1>
<img src="{{ image }}" alt="Here is your pic">
<br />
<br />
<button type="button" onclick="dont_touch_me()">别点我 Σ(っ°Д °;)っ</button>
<script src="{{ js }}"></script>
</body>

</html>
12 changes: 12 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/step3_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<head>
<title>
Hello Dalao
</title>
</head>
<body>
{% block first %}{% endblock %}
{% block second %}{% endblock %}
</body>
</html>
17 changes: 17 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/step3_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<title>
Hello Dalao
</title>
</head>

<body>
<form>
Title: <input type="text" name="title" placeholder="your title here"><br>
Name: <input type="text" name="name" placeholder="your name here"><br>
<input type="submit" value="Go!">
</form>
</body>

</html>
9 changes: 9 additions & 0 deletions stage1/Xiaoguang_Zhu/templates/step3_userpage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "step3_base.html" %}

{% block first %}
<p>Hello, {{ name }}! You are {{ title }}.</p>
{% endblock %}

{% block second %}
{{ something|safe }}
{% endblock %}