"old stable"
This commit is contained in:
16
tetastock.py
16
tetastock.py
@@ -7,7 +7,7 @@ from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('config.py')
|
||||
app.secret_key = app.config.get('446307a5f61c2bb810436b2ee0f903f2')
|
||||
app.secret_key = '446307a5f61c2bb810436b2ee0f903f2'
|
||||
app.debug = True
|
||||
app.static_url_path='/static'
|
||||
db = SQLAlchemy(app)
|
||||
@@ -61,7 +61,9 @@ def authenticate():
|
||||
########################################################################
|
||||
@app.route('/componants', methods=['GET', 'POST'])
|
||||
def get_componants():
|
||||
limit = 16
|
||||
if not session or not session['plop']:
|
||||
session['plop']='plip'
|
||||
limit = 8
|
||||
offset = 0
|
||||
sort = 'reference'
|
||||
order = 'asc'
|
||||
@@ -78,6 +80,7 @@ def get_componants():
|
||||
offset = int(offset)
|
||||
except ValueError:
|
||||
offset = 0
|
||||
providers = Stock_providers.query.order_by(Stock_providers.name).all()
|
||||
row_count = db.session.query(Stock_componants.id).count()
|
||||
page_count = int(math.ceil(row_count / float(limit)))
|
||||
page = int(math.ceil(float(offset + 1) / float(limit)))
|
||||
@@ -95,6 +98,7 @@ def get_componants():
|
||||
componants = Stock_componants.query.order_by(getattr(Stock_componants, sort).desc()).offset(offset).limit(limit).all()
|
||||
return render_template('componants.html',
|
||||
componants=componants,
|
||||
providers = providers,
|
||||
offset=offset,
|
||||
nexthop=nexthop,
|
||||
prevhop=prevhop,
|
||||
@@ -106,6 +110,7 @@ def get_componants():
|
||||
|
||||
@app.route('/componants/<componant_id>')
|
||||
def get_componant(componant_id):
|
||||
print session['plop']
|
||||
try:
|
||||
componant_id = int(componant_id)
|
||||
except ValueError as e:
|
||||
@@ -236,8 +241,9 @@ def search_users():
|
||||
return render_template('wip.html')
|
||||
|
||||
##############################################
|
||||
|
||||
def get_distinct(query):
|
||||
# SQL
|
||||
##############################################
|
||||
def sql_get_distinct(query):
|
||||
results = []
|
||||
for result in query:
|
||||
result = result[0]
|
||||
@@ -248,4 +254,4 @@ def get_distinct(query):
|
||||
# Main #######################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
app.run(host='0.0.0.0')
|
||||
|
||||
Reference in New Issue
Block a user