-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (28 loc) · 1017 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, render_template, url_for, send_file
from MySQLdb import *
from passwd import db_passwd # Set your password as db_passwd in passwd.py
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/projects/')
def projects():
db = connect('GordonZhang.mysql.pythonanywhere-services.com', 'GordonZhang', db_passwd, 'GordonZhang$website')
cursor = db.cursor()
cursor.execute('SELECT * FROM projects')
projects_list = cursor.fetchall()
projects = list(projects_list)
lenth = len(projects_list)
return render_template('projects.html', projects_list=projects_list, lenth=lenth)
@app.route('/projects/tkMarker/')
def tkmarker():
return render_template('tkmarker.html')
@app.route('/robots.txt')
def robotstxt():
return send_file('robots.txt')
@app.route('/sitemap.xml')
def sitemap():
return send_file('sitemap.xml')
@app.errorhandler(404)
def pagenotfound(arg):
return render_template('404.html'), 404