add new func
This commit is contained in:
80
app.py
80
app.py
@@ -1,18 +1,14 @@
|
||||
from flask import Flask, render_template, redirect, url_for, request, jsonify
|
||||
from models import db, CommissionPersons
|
||||
from flask_migrate import Migrate
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
|
||||
app.jinja_env.auto_reload = True
|
||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
db.init_app(app)
|
||||
migrate = Migrate(app, db)
|
||||
|
||||
|
||||
|
||||
|
||||
app.secret_key = '6523e58bc0eec42c31b9635d5e0dfc23b6d119b73e633bf3a5284c79bb4a1edeaskldj'
|
||||
|
||||
|
||||
@@ -20,21 +16,89 @@ app.secret_key = '6523e58bc0eec42c31b9635d5e0dfc23b6d119b73e633bf3a5284c79bb4a1e
|
||||
def index():
|
||||
return "22222"
|
||||
|
||||
|
||||
@app.route("/settings", methods=["GET", "POST"])
|
||||
def settings():
|
||||
return render_template('settnigs.html')
|
||||
|
||||
|
||||
@app.route("/addperson", methods=["GET", "POST"])
|
||||
def addperson():
|
||||
if request.method == "GET":
|
||||
fio = request.args.get("fio")
|
||||
predsed = request.args.get("predsed")
|
||||
recent = request.args.get("recent")
|
||||
print(fio)
|
||||
print(predsed)
|
||||
print(recent)
|
||||
secretar = request.args.get("secretar")
|
||||
|
||||
ispred = False
|
||||
isrecenz = False
|
||||
issecretar = False
|
||||
|
||||
if predsed == "true":
|
||||
ispred = True
|
||||
|
||||
if recent == "true":
|
||||
isrecenz = True
|
||||
|
||||
if secretar == "true":
|
||||
issecretar = True
|
||||
|
||||
db.session.add(CommissionPersons(fio=fio,
|
||||
ispredsedatel=ispred,
|
||||
isrecenzent=isrecenz,
|
||||
issecretar=issecretar))
|
||||
db.session.commit()
|
||||
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||
|
||||
|
||||
@app.route("/createcommision", methods=["GET", "POST"])
|
||||
def createcommision():
|
||||
return render_template("createCommision.html")
|
||||
|
||||
|
||||
@app.route("/1", methods=["GET", "POST"])
|
||||
def one():
|
||||
if request.method == "GET":
|
||||
return "111111"
|
||||
|
||||
|
||||
@app.route("/gu", methods=["GET", "POST"])
|
||||
def getuchastniki():
|
||||
if request.method == "GET":
|
||||
data = db.session.query(CommissionPersons).all()
|
||||
data_dct = []
|
||||
for item in data:
|
||||
data_dct.append(
|
||||
{
|
||||
'fio': item.fio,
|
||||
'predsed': item.ispredsedatel,
|
||||
'recent': item.isrecenzent,
|
||||
'secretar': item.issecretar
|
||||
}
|
||||
)
|
||||
|
||||
return jsonify(data_dct)
|
||||
|
||||
|
||||
@app.route("/addcommision", methods=["GET", "POST"])
|
||||
def addcommision():
|
||||
if request.method == "GET":
|
||||
predsdatel = request.args.get("predsdatel")
|
||||
uchastnik1 = request.args.get("uchastnik1")
|
||||
uchastnik2 = request.args.get("uchastnik2")
|
||||
uchastnik3 = request.args.get("uchastnik3")
|
||||
uchastnik4 = request.args.get("uchastnik4")
|
||||
secretar = request.args.get("secretar")
|
||||
|
||||
pred = db.session.query(CommissionPersons).filter(CommissionPersons.fio == predsdatel).first()
|
||||
uch1 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik1).first()
|
||||
uch2 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik2).first()
|
||||
uch3 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik3).first()
|
||||
uch4 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik4).first()
|
||||
secr = db.session.query(CommissionPersons).filter(CommissionPersons.fio == secretar).first()
|
||||
|
||||
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0", port=3800)
|
||||
|
||||
Reference in New Issue
Block a user