-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
57 lines (46 loc) · 1.68 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from flask import Flask, render_template, request, redirect
# from flask_mysqldb import MySQL
import MySQLdb
import yaml
app = Flask(__name__)
db = yaml.load(open('static/data/db.yaml'))
# app.config['MYSQL_HOST'] = db['mysql_host']
# app.config['MYSQL_USER'] = db['mysql_user']
# app.config['MYSQL_PASSWORD'] = db['mysql_password']
try:
db_connection = MySQLdb.connect(db['mysql_host'], db['mysql_user'], db['mysql_password'])
cursor = db_connection.cursor()
cursor.execute(
open("static/data/db_install.sql", "r").read().replace("--DB_NAME--", db["mysql_db"]))
mysql = MySQLdb.connect(
db['mysql_host'], db['mysql_user'], db['mysql_password'], db['mysql_db'])
except Exception as e:
print("Eror:"+ str(e))
# mysql = MySQL(app)
@app.route('/', methods = ['GET', 'POST'])
def index():
print(request.method)
if request.method == 'POST':
userDetails = request.form
email = userDetails['email']
cursor = mysql.cursor()
cursor.execute('INSERT INTO emails (email) VALUES("%s")' % (email))
mysql.commit()
# cursor = mysql.connection.cursor()
# cursor.execute('INSERT INTO emails (email) VALUES("%s")' % (email))
# mysql.connection.commit()
# cursor.close()
return redirect('portfol.html')
return redirect('email.html')
return render_template('index.html')
@app.route('/email.html')
def email():
return render_template('email.html')
@app.route('/portfol.html')
def portfol():
return render_template('portfol.html')
@app.route('/porjikt_cv.html')
def porjikt_cv():
return render_template('porjikt_cv.html')
if __name__ == "__main__":
app.run(port = 9991, debug = True)