-
Notifications
You must be signed in to change notification settings - Fork 0
/
hackbright-web.py
49 lines (36 loc) · 1.44 KB
/
hackbright-web.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
38
39
40
41
42
43
44
45
46
47
48
49
from flask import Flask, request, render_template
import hackbright
app = Flask(__name__)
import sqlite3
db_connection = sqlite3.connect("hackbright.db", check_same_thread=False)
db_cursor = db_connection.cursor()
@app.route("/student")
def get_student():
"""Show information about a student."""
github = request.args.get('github', 'name')
first, last, github = hackbright.get_student_by_github(github)
# return "%s is the GitHub account for %s %s" % (github, first, last)
html = render_template("student_info.html",
first=first,
last=last,
github=github)
return html
@app.route("/student-search")
def get_student_form():
"""Show form for searching for a student."""
return render_template("student_search.html")
@app.route("/student-add") #, methods=['POST'])
def make_new_student():
"""Add a new student and print confirmation.
Given a first name, last name, and GitHub account, add student to the
database and print a confirmation message.
"""
#first_name, last_name, github
# request.form.get()
# QUERY = """INSERT INTO Students VALUES (?, ?, ?)"""
# db_cursor.execute(QUERY, (first_name, last_name, github))
# db_connection.commit()
# print "Successfully added student: %s %s" % (first_name, last_name)
return render_template("student-add.html")
if __name__ == "__main__":
app.run(debug=True)