-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
52 lines (34 loc) · 1.04 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
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app)
class Sortable(db.Model):
__tablename__ = 'sortables'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
data = db.Column(db.String)
def __init__(self, data):
self.data = data
db.create_all()
a = '12345'
b = Sortable(a)
db.session.add(b)
db.session.commit()
@app.route('/')
def index():
sort = Sortable.query.filter_by(id=1).first()
ordem = str(sort.data)
return render_template('index.html', ordem=ordem)
@app.route('/post', methods=['GET', 'POST'])
def post():
json = request.json
x = json.replace('item[]=', ',')
y = x.replace('&,', '')
final = y.replace(',', '')
sort = Sortable.query.filter_by(id=1).first()
sort.data = final
db.session.commit()
return str('')
if __name__ == '__main__':
app.run(debug=True)