-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
74 lines (65 loc) · 2.41 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from flask import Flask, render_template, session, request, redirect, url_for
from functions import Administrator
from models import DB
app = Flask(__name__)
db = DB(app)
app.secret_key = 'your secret key'
@app.route('/', methods=['GET', 'POST'])
def create_account():
if request.method == "POST":
admin = Administrator(app, db)
details = request.form
id_no = details['account_id_no']
name = details['account_name']
state = details['account_state']
phone = details['account_phone']
result = admin.account_creator(id_no, name, state, phone)
return result
#else:
#return render_template('administrator/create_account.html')
#return render_template('administrator/home.html')
@app.route('/administrator', methods=['GET', 'POST'])
def administrator_index():
msg = ''
# Check if the user is logged in
if 'loggedin' in session:
return render_template('administrator/home.html')
else:
if request.method == 'POST' and 'username' in request.form and 'password' in request.form:
username = request.form['username']
password = request.form['password']
administrator = Administrator(app, db)
msg = administrator.login(username, password)
if msg == "ghoori":
return render_template('administrator/home.html')
return render_template('administrator/index.html', msg=msg)
@app.route('/logout')
def logout():
# Remove session data, this will log the user out
session.pop('loggedin', None)
session.pop('id', None)
session.pop('username', None)
return "done"
@app.route('/jjjjlguvgfol')
def index():
id_no = "0123"
description = "این یک نمونه از توضیحات است"
unit = "متر مکعب"
cost = "1230000"
tags = "حفاری"
result = db.insert_to_tariff_list(id_no, description, unit, cost, tags)
return result
"""@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == "POST":
details = request.form
firstName = details['fname']
lastName = details['lname']
cur = mysql.connection.cursor()
cur.execute("INSERT INTO name(firstname, lastname) VALUES (%s, %s)", (firstName, lastName))
mysql.connection.commit()
cur.close()
return 'success'
return render_template('list.html')"""
if __name__ == '__main__':
app.run()