felix 3 years ago
parent
commit
dc2cf078d9
4 changed files with 27 additions and 21 deletions
  1. 5 21
      frog.py
  2. 3 0
      templates/footer.html
  3. 16 0
      templates/header.html
  4. 3 0
      templates/index2.html

+ 5 - 21
frog.py

@@ -14,6 +14,10 @@ def internal_server_error(e):
 def index():
     return render_template('index.html')
 
+@app.route('/index2')
+def index2():
+    return render_template('index2.html',title='Index - Frog')
+
 @app.route('/post/')
 def posts():
     allposts=[{'id':1,'title':'title1'},{'id':2,'title':'title2'}]
@@ -21,24 +25,4 @@ def posts():
 
 @app.route('/post/<int:id>')
 def post(id):
-    return render_template('post.html',id=id)
-
-@app.route('/article/')
-def article():
-    return redirect(url_for('posts'))
-
-from flask import abort
-
-@app.route('/i-love/<obj>')
-def ilove(obj):
-    if obj=='shit':
-        abort(404)
-    return '<h1>I love %s</h1>' % obj
-
-@app.route('/<int:num1>/plus/<int:num2>/eq/<int:num3>')
-def count(num1,num2,num3):
-    if num1+num2==num3:
-        flash('计算正确')
-    else:
-        flash('计算错误')
-    return redirect(url_for('index'))
+    return render_template('post.html',id=id)

+ 3 - 0
templates/footer.html

@@ -0,0 +1,3 @@
+        </div>
+    </body>
+</html>

+ 16 - 0
templates/header.html

@@ -0,0 +1,16 @@
+<html>
+    <head>
+        <title>{{ title }}</title>
+        <link rel="stylesheet" href="//cdnjs.loli.net/ajax/libs/mdui/0.4.3/css/mdui.min.css">
+        <script src="//cdnjs.loli.net/ajax/libs/mdui/0.4.3/js/mdui.min.js"> var SS=mdui.JQ;</script>
+        <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
+        <link rel='stylesheet' href="{{ url_for('static',filename='style.css') }}">
+        <script src="{{ url_for('static',filename='myfunction.js') }}"></script>
+    </head>
+    <body class='mdui-theme-primary-light-green'>
+        <div class="mdui-toolbar mdui-color-theme">
+            <a href='/' class='mdui-typo-headline mdui-text-color-white' style='font-weight:bold'>Frog</a>
+            <a href='/' class='mdui-text-color-white'>首页</a>
+            <a href="{{ url_for('posts') }}" class='mdui-text-color-white'>文章</a>
+        </div>
+        <div class='mdui-container'>

+ 3 - 0
templates/index2.html

@@ -0,0 +1,3 @@
+{% include 'header.html' %}
+<h1>hello world!</h1>
+{% include 'footer.html' %}