some func
This commit is contained in:
45
app.py
45
app.py
@@ -6,6 +6,7 @@ from flask_migrate import Migrate
|
||||
from datetime import *
|
||||
import csv
|
||||
import random
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -77,10 +78,12 @@ def searchonaud():
|
||||
results = []
|
||||
for auditory, oboruds in q:
|
||||
results.append({
|
||||
'num_ved': oboruds.numberved,
|
||||
'auditory_id': auditory.id,
|
||||
'auditory_name': auditory.audnazvanie,
|
||||
'inv_number': oboruds.invNumber,
|
||||
'oboruds_id': oboruds.nazvanie,
|
||||
'raspolog': oboruds.raspologenie,
|
||||
})
|
||||
return jsonify(results)
|
||||
|
||||
@@ -183,30 +186,24 @@ def zamsearch():
|
||||
@app.route('/addraspved', methods=['GET', 'POST'])
|
||||
def addraspved():
|
||||
if request.method == 'POST':
|
||||
query_string = request.data
|
||||
# Convert the bytes object to a string
|
||||
query_string_str = query_string.decode("utf-8")
|
||||
|
||||
# Split the query string by '&' to get individual key-value pairs
|
||||
key_value_pairs = query_string_str.split("&")
|
||||
query_string = request.data.decode()
|
||||
|
||||
# Create a dictionary to store the key-value pairs
|
||||
query_dict = {}
|
||||
for pair in key_value_pairs:
|
||||
key, value = pair.split("=")
|
||||
query_dict[key] = value
|
||||
print(query_string)
|
||||
un_query_string = unquote(unquote(query_string)).split(',')
|
||||
|
||||
# Retrieve the values for specific keys
|
||||
rasp_value = query_dict.get("rasp")
|
||||
ved_value = query_dict.get("ved")
|
||||
|
||||
print(f"Value for 'rasp': {rasp_value}")
|
||||
print(f"Value for 'ved': {ved_value}")
|
||||
print(un_query_string)
|
||||
|
||||
|
||||
|
||||
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||
|
||||
|
||||
ob = db.session.query(Oboruds).filter_by(invNumber=un_query_string[0]).first()
|
||||
ob.raspologenie=un_query_string[2]
|
||||
ob.numberved = un_query_string[1]
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
|
||||
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
@@ -262,16 +259,6 @@ def createdb():
|
||||
|
||||
db.session.commit()
|
||||
|
||||
"""
|
||||
with open('zabalans.csv', encoding='utf-8') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
for row in csv_reader:
|
||||
print(row)
|
||||
db.session.add(
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
||||
|
||||
db.session.commit()
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user