Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.35 KB | None | 0 0
  1. from flask import Flask, render_template, request
  2. from flask import redirect, url_for, flash, session, abort
  3. from flask_caching import Cache
  4. from secrets import *
  5. from lists import *
  6. from search import *
  7. import os, requests, re
  8. import pymssql, datetime, atexit
  9.  
  10. app = Flask(__name__)
  11. app.config.from_object(__name__)
  12. app.config['SECRET_KEY'] = 'VERYSECRET!!'
  13. cache = Cache(app,config={'CACHE_TYPE': 'simple'})
  14.  
  15. currentUser = ""
  16. cfUser = 0
  17. nrUser = 0
  18. editID = 0
  19.  
  20. @app.route("/")
  21. def main():
  22.  
  23.     if not session.get('logged_in'):
  24.         return render_template('login.html')
  25.     else:
  26.         if check_user() == "CF":
  27.             return render_template('index.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  28.             listFiliale = listFiliale, listGroup = listGroup)
  29.         elif check_user() =="NR":
  30.             return render_template('indexN.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  31.             listFiliale = listFiliale, listGroup = listGroup)
  32.  
  33. def check_user():
  34.  
  35.     if cfUser>0: return "CF"
  36.     if nrUser>0: return "NR"
  37.     return
  38.  
  39.  
  40. @app.route('/login', methods=['POST'])
  41. def login():
  42.  
  43.     global cfUser
  44.     global nrUser
  45.     global currentUser
  46.  
  47.     user = request.form['user']
  48.     password = request.form['password']
  49.  
  50.     if (user in loginDict and user == "neuroth" and password == loginDict[user]):
  51.         currentUser = user
  52.         nrUser += 1
  53.         session['logged_in'] = True
  54.     elif (user in loginDict and password == loginDict[user]):
  55.         currentUser = user
  56.         cfUser += 1
  57.         session['logged_in'] = True
  58.  
  59.     return main()
  60.  
  61.  
  62. @app.route("/logout", methods=['POST'])
  63. def logout():
  64.  
  65.     global cfUser
  66.     global nrUser
  67.  
  68.     cfUser = 0
  69.     nrUser = 0
  70.  
  71.     session['logged_in'] = False
  72.  
  73.     return main()
  74.  
  75.  
  76. @app.route("/clear", methods=['POST'])
  77. def clear():
  78.  
  79.     return render_template('add.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  80.     listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  81.     listJahr = listJahr)
  82.  
  83.  
  84. @app.route("/delete", methods=['POST'])
  85. def delete():
  86.  
  87.     return render_template('index.html', currentUser = currentUser, listLocation = listLocation,
  88.     listStatus = listStatus, listFiliale = listFiliale, listGroup = listGroup)
  89.  
  90.  
  91. @app.route("/activity", methods=['POST'])
  92. def activity():
  93.  
  94.     queryActivity = """Select * from %s""" % 'Activity'
  95.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  96.     cursor = conn.cursor()
  97.     cursor.execute(queryActivity)
  98.     activityData = cursor.fetchall()
  99.     conn.close()
  100.  
  101.     return render_template('activity.html', activityData = activityData, currentUser = currentUser)
  102.  
  103. @app.route('/history', methods=['GET', 'POST'])
  104. def history():
  105.  
  106.     id_dict = (request.form.to_dict())
  107.     fk_id = (list(id_dict.keys())[1])
  108.     search_history = """Select * from History where Fk_ID_LagerstandIT=%s""" % fk_id
  109.  
  110.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  111.     cursor = conn.cursor()
  112.     cursor.execute(search_history)
  113.     history_data = cursor.fetchall()
  114.     count = str(len(history_data))
  115.     conn.close()
  116.  
  117.     flash("Number of results: "+count)
  118.  
  119.     parcel_status()
  120.  
  121.     return render_template('history.html', currentUser = currentUser, history_data=history_data)
  122.  
  123.  
  124. @app.route('/new', methods=['POST'])
  125. def redirectAdd():
  126.  
  127.     if check_user() == "NR": return render_template('no.html')
  128.  
  129.     return render_template('add.html', listLocation = listLocation, currentUser = currentUser, listStatus = listStatus,
  130.         listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  131.         listJahr = listJahr)
  132.  
  133.  
  134. @app.route('/add', methods=['GET', 'POST'])
  135. def add():
  136.  
  137.     now = str(datetime.datetime.now())
  138.  
  139.     if check_user() == "NR": return render_template('no.html')
  140.  
  141.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  142.     cursor = conn.cursor()
  143.     isInput = 0
  144.     data = ['0']
  145.  
  146.     if request.method == 'POST':
  147.  
  148.  
  149.         serialNr = request.form["serialNr"]
  150.         model = request.form["deviceModel"]
  151.         comments = request.form["besonderes"]
  152.         status = request.form.get('list_status')
  153.         location = request.form.get('list_location')
  154.         filiale = request.form.get('list_filiale')
  155.         group = request.form.get('list_group')
  156.         tag = request.form.get('list_tag')
  157.         monat = request.form.get('list_monat')
  158.         jahr = request.form.get('list_jahr')
  159.  
  160.         if status == "Select Status": isInput += 1
  161.         if location == "Select Neuroth": isInput += 1
  162.         if filiale == "Select Filiale": isInput += 1
  163.         if group == "Select Group": isInput += 1
  164.         if tag == "Tag Wählen": isInput += 1
  165.         if monat == "Monat Wählen": isInput += 1
  166.         if jahr == "Jahr Wählen": isInput += 1
  167.         if (serialNr or model) == "":
  168.             isInput += 1
  169.  
  170.         if isInput>0:
  171.  
  172.             flash("Please fill in all information.")
  173.  
  174.             return render_template('add.html', listLocation = listLocation, currentUser = currentUser, listStatus = listStatus,
  175.                 listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  176.                 listJahr = listJahr)
  177.  
  178.         query = """INSERT INTO LagerstandIT (Lager_Bewegung, Jahr, Monat, Tag, Neuroth, Filiale, ArtikelGruppe,
  179.             ArtikelKorrekt, SerienNr, Besonderes) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',
  180.             '%s')""" % (status, jahr, monat, tag, location, filiale, group, model, serialNr, comments)
  181.  
  182.         queryReplaced = query.replace("'", '"')
  183.         queryActivity = """INSERT INTO Activity (Who, Date, Action) VALUES ('{0}', '{1}', '{2}')""".format(currentUser, now, queryReplaced)
  184.  
  185.  
  186.         flash(queryActivity)
  187.         cursor.execute(query)
  188.         cursor.execute(queryActivity)
  189.         conn.commit()
  190.         cursor.close()
  191.         data = sql_serial(serialNr)
  192.  
  193.         return render_template('add.html', data = data, currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  194.             listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  195.             listJahr = listJahr)
  196.  
  197.     else:
  198.         cursor.close()
  199.  
  200.         return render_template('add.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  201.                     listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  202.             listJahr = listJahr)
  203.  
  204.  
  205. @app.route('/editor', methods=['POST'])
  206. def redirectEdit():
  207.  
  208.     global editID
  209.  
  210.     id_dict = (request.form.to_dict())
  211.     id = (list(id_dict.keys())[1])
  212.     editID = id
  213.  
  214.     query = """ Select * from LagerstandIT where ID=%s""" % id
  215.     queryInfoHistory = """Select * from History where Fk_ID_LagerstandIT = %s""" % editID
  216.  
  217.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  218.     cursor = conn.cursor()
  219.     cursor.execute(query)
  220.     data = cursor.fetchall()
  221.     listData = data[0]
  222.  
  223.     cursor.execute(queryInfoHistory)
  224.     listHistory = cursor.fetchall()
  225.  
  226.     if (len(listHistory) == 0):
  227.         listDataHistory =  ""
  228.     else:
  229.         listDataHistory = listHistory[(len(listHistory)-1)]
  230.  
  231.     conn.close()
  232.  
  233.     return render_template('edit.html', listDataHistory = listDataHistory, currentUser = currentUser, data = data, listData = listData, listLocation = listLocation, listStatus = listStatus,
  234.         listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  235.         listJahr = listJahr)
  236.  
  237.  
  238. @app.route('/edit', methods=['POST'])
  239. def edit():
  240.  
  241.     now = str(datetime.datetime.now())
  242.  
  243.     queryInfo = """Select * from LagerstandIT where ID = %s""" % editID
  244.     queryInfoHistory = """Select * from History where Fk_ID_LagerstandIT = %s""" % editID
  245.  
  246.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  247.     cursor = conn.cursor()
  248.     cursor.execute(queryInfo)
  249.     list = cursor.fetchall()
  250.     listData = list[0]
  251.  
  252.     cursor.execute(queryInfoHistory)
  253.     listHistory = cursor.fetchall()
  254.  
  255.     if (len(listHistory) == 0):
  256.         listDataHistory =  ""
  257.     else:
  258.         listDataHistory = listHistory[(len(listHistory)-1)]
  259.  
  260.     if request.method == 'POST':
  261.  
  262.         serialNr = request.form['serialNr']
  263.         neurothNr = request.form['neurothNr']
  264.         ticketCF = request.form['ticketCF']
  265.         ticketNR = request.form['ticketNR']
  266.         tracking = request.form['trackingNr']
  267.         model = request.form['deviceModel']
  268.         comments = request.form['besonderes']
  269.         status = request.form.get("list_status")
  270.         statusHistory = request.form.get("list_status")
  271.         location = request.form.get('list_location')
  272.         filiale = request.form.get('list_filiale')
  273.         group = request.form.get('list_group')
  274.         tag = request.form.get('list_tag')
  275.         monat = request.form.get('list_monat')
  276.         jahr = request.form.get('list_jahr')
  277.  
  278.         if serialNr: serialNr = "SerienNr = '%s', " % serialNr
  279.         if neurothNr: neurothNr = "NeurothNr = '%s', " % neurothNr
  280.         if model: model = "ArtikelKorrekt = '%s', " % model
  281.         if comments: comments = "Besonderes = '%s', " % comments
  282.  
  283.         if statusHistory == "Select Status": statusHistory = ""
  284.  
  285.         if status == "Select Status":
  286.             status = ""
  287.         else:
  288.             status = "Lager_Bewegung = '%s', " % status
  289.  
  290.         if location == "Select Neuroth":
  291.             location = ""
  292.         else:
  293.             location = "Neuroth = '%s', " % location
  294.  
  295.         if filiale == "Select Filiale":
  296.             filiale = ""
  297.         else:
  298.             filiale = "Filiale = '%s', " % filiale
  299.  
  300.         if group == "Select Group":
  301.             group = ""
  302.         else:
  303.             group = "ArtikelGruppe = '%s', " % group
  304.  
  305.         if tag == "Tag Wählen":
  306.             tag = ""
  307.         else:
  308.             tag = "Tag = '%s', " % tag
  309.  
  310.         if monat == "Monat Wählen":
  311.             monat = ""
  312.         else:
  313.             monat = "Monat = '%s', " % monat
  314.  
  315.         if jahr == "Jahr Wählen":
  316.             jahr = ""
  317.         else:
  318.             jahr = "Jahr = '%s', " % jahr
  319.  
  320.         query = """UPDATE LagerstandIT SET {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10} WHERE ID = {11}""".format(serialNr,
  321.         neurothNr, model, comments, status, location, filiale, group, tag, monat, jahr, editID)
  322.  
  323.         """
  324.         if (tracking or ticketCF or ticketNR) and not (serialNr or neurothNr or model or comments or status or location
  325.             or filiale or group or tag or monat or jahr):
  326.  
  327.  
  328.             pkCount = getPkCount()
  329.             queryHistory = editHistory(statusHistory, tracking, ticketCF, ticketNR, pkCount)
  330.  
  331.             conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  332.             cursor = conn.cursor()
  333.             cursor.execute(queryHistory)
  334.             conn.commit()
  335.             cursor.execute(queryInfo)
  336.             data = cursor.fetchall()
  337.             listdata = data[0]
  338.             conn.close()
  339.  
  340.             flash("Entered: "+queryHistory)
  341.  
  342.             return render_template('edit.html', currentUser = currentUser, listDataHistory = listDataHistory, listData = listData, data = data, listLocation = listLocation, listStatus = listStatus,
  343.             listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  344.             listJahr = listJahr)
  345.         """
  346.  
  347.         if (tracking or ticketCF or ticketNR):
  348.  
  349.             pkCount = getPkCount()
  350.             queryHistory = editHistory(statusHistory, tracking, ticketCF, ticketNR, pkCount)
  351.  
  352.             flash("Entered: "+queryHistory)
  353.  
  354.             conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  355.             cursor = conn.cursor()
  356.             cursor.execute(queryHistory)
  357.  
  358.             queryReplaced = queryHistory.replace("'", '"')
  359.             queryActivity = """INSERT INTO Activity (Who, Date, Action) VALUES ('{0}', '{1}', '{2}')""".format(currentUser,
  360.             now, queryReplaced)
  361.  
  362.             cursor.execute(queryActivity)
  363.  
  364.             conn.commit()
  365.             conn.close()
  366.  
  367.         split = re.split(' (?=WHERE)', query)
  368.         str1 = str(split[0])
  369.         str1 = str1[:-2]
  370.         queryChange = str1+" "+str(split[1])
  371.  
  372.         conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  373.         cursor = conn.cursor()
  374.         cursor.execute(queryChange)
  375.  
  376.         queryReplaced = queryChange.replace("'", '"')
  377.         queryActivity = """INSERT INTO Activity (Who, Date, Action) VALUES ('{0}', '{1}', '{2}')""".format(currentUser,
  378.             now, queryReplaced)
  379.  
  380.         print(queryActivity)
  381.         cursor.execute(queryActivity)
  382.         conn.commit()
  383.         cursor.execute(queryInfo)
  384.         data = cursor.fetchall()
  385.         listData = data[0]
  386.  
  387.         flash("Entered: "+queryChange)
  388.  
  389.         cursor.execute(queryInfoHistory)
  390.         listHistory = cursor.fetchall()
  391.         if (len(listHistory) == 0):
  392.             listDataHistory =  ""
  393.         else:
  394.             listDataHistory = listHistory[(len(listHistory)-1)]
  395.  
  396.         conn.close()
  397.  
  398.         return render_template('edit.html', data = data, listData = listData, listDataHistory = listDataHistory, currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  399.         listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  400.         listJahr = listJahr)
  401.  
  402.     return render_template('edit.html', listDataHistory = listDataHistory, listLocation = listLocation, listData = listData, currentUser = currentUser, listStatus = listStatus,
  403.         listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  404.         listJahr = listJahr)
  405.  
  406.  
  407. def editHistory(statusHistory, tracking, ticketCF, ticketNR, pkCount):
  408.  
  409.  
  410.         count = 0
  411.  
  412.         subStat = ""
  413.         subTrack = ""
  414.         subTickCF = ""
  415.         subTickNR = ""
  416.         historyDate = "History_Date, "
  417.         subID = "Fk_ID_LagerstandIT, "
  418.         subIDPK = "Pk_ID_History, "
  419.         now = "'"+str(datetime.datetime.now())+"', "
  420.         subUser = "Activity, "
  421.         user = "'"+currentUser+"', "
  422.         PK = pkCount
  423.  
  424.         if statusHistory:
  425.             count += 1
  426.             statusHistory = "'"+statusHistory+"'"+", "
  427.             subStat = "Movement, "
  428.         if tracking:
  429.             count += 1
  430.             tracking = "'"+tracking+"'"+", "
  431.             subTrack = "Parcel_Code, "
  432.         if ticketCF:
  433.             count += 1
  434.             ticketCF = "'"+ticketCF+"'"+", "
  435.             subTickCF = "Ticket_Number_CF, "
  436.         if ticketNR:
  437.             count += 1
  438.             ticketNR = "'"+ticketNR+"'"+", "
  439.             subTickNR = "Ticket_Number_NR, "
  440.  
  441.         query = """INSERT into History ({0}{1}{2}{3}{4}{5}{6}{7}) VALUES ({8}, {9}{10}{11}{12}{13}{14}{15})""".format(subIDPK, subStat, subTrack, subTickCF,
  442.         subTickNR, historyDate, subUser, subID, PK, statusHistory, tracking, ticketCF, ticketNR, now, user, editID)
  443.  
  444.         split = re.split(' (?=VALUES)', query)
  445.         str1 = str(split[0])
  446.         str1 = str1[:-3]
  447.         queryHistory = str1+") "+str(split[1])
  448.  
  449.         print(queryHistory)
  450.         return queryHistory
  451.  
  452.  
  453. def getPkCount():
  454.  
  455.     query = """SELECT COUNT(*) FROM History"""
  456.  
  457.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  458.     cursor = conn.cursor()
  459.     cursor.execute(query)
  460.     pkCount = cursor.fetchone()
  461.     conn.close()
  462.  
  463.     pkCount = pkCount[0]
  464.     pkCount += 2
  465.  
  466.     return pkCount
  467.  
  468.  
  469. @app.route('/home', methods=['POST'])
  470. def redirectHome():
  471.  
  472.     if check_user() == "NR":
  473.  
  474.         return render_template('indexN.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  475.         listFiliale = listFiliale, listGroup = listGroup)
  476.  
  477.     return render_template('index.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  478.         listFiliale = listFiliale, listGroup = listGroup, listTag = listTag, listMonat = listMonat,
  479.         listJahr = listJahr)
  480.  
  481.  
  482. @app.route('/search', methods=['GET', 'POST'])
  483. def input():
  484.  
  485.     inputCount = 0
  486.  
  487.     if request.method == 'POST':
  488.  
  489.         serialNr = request.form["serialNr"]
  490.         neurothNr = request.form["neurothNr"]
  491.         status = request.form.get('list_status')
  492.         location = request.form.get('list_location')
  493.         filiale = request.form.get('list_filiale')
  494.         group = request.form.get('list_group')
  495.         entered = "You've entered: "
  496.  
  497.         if status != 'Select Status': inputCount += 1
  498.         if location != 'Select Neuroth': inputCount += 1
  499.         if filiale != 'Select Filiale': inputCount += 1
  500.         if group != 'Select Group': inputCount += 1
  501.  
  502.         if inputCount>0:
  503.             if status != 'Select Status':
  504.                 entered += status
  505.             if location != 'Select Neuroth':
  506.                 entered += " ---> "+location
  507.             if filiale != 'Select Filiale':
  508.                 entered += " ---> "+filiale
  509.             if group != 'Select Group':
  510.                 entered += " ---> "+group
  511.             flash(entered)
  512.  
  513.         if (inputCount == 0 and serialNr == '' and neurothNr == ""):
  514.             data = sql_all()
  515.         elif (serialNr == '' and neurothNr == "" and inputCount>0):
  516.             data = sql_list(inputCount)
  517.         elif (serialNr == "" and neurothNr != ''):
  518.             data = sql_neuroth(neurothNr)
  519.         elif (serialNr != "" and neurothNr == ''):
  520.             data = sql_serial(serialNr)
  521.         elif (serialNr != "" and neurothNr != ''):
  522.  
  523.             flash("Please enter either serial number OR neuroth number.")
  524.  
  525.             if check_user() == "NR":
  526.  
  527.                 return render_template('indexN.html', currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  528.                 listFiliale = listFiliale, listGroup = listGroup)
  529.  
  530.             return render_template('index.html', currentUser = currentUser, listLocation = listLocation,
  531.                         listStatus = listStatus, listFiliale = listFiliale, listGroup = listGroup)
  532.  
  533.         if check_user() == "NR":
  534.  
  535.             return render_template('indexN.html', data = data, currentUser = currentUser, listLocation = listLocation, listStatus = listStatus,
  536.             listFiliale = listFiliale, listGroup = listGroup)
  537.  
  538.         return render_template('index.html', data=data, currentUser = currentUser, listLocation = listLocation,
  539.             listStatus = listStatus, listFiliale = listFiliale, listGroup = listGroup)
  540.     else:
  541.         return render_template('index.html')
  542.  
  543.  
  544. def parcel_status():
  545.  
  546.     search_status = """select Parcel_Code,Pk_ID_History from dbo.History WHERE NOT Status='Zugestellt' OR Status IS NULL"""
  547.  
  548.     conn = pymssql.connect(server=server, user=user, password=password, database=database, port=port)
  549.     cursor = conn.cursor()
  550.     cursor.execute(search_status)
  551.  
  552.     for parcel in cursor:
  553.         try:
  554.             post_link = 'https://www.post.ch/swisspost-tracking?formattedParcelCodes='
  555.             post_link = post_link + str(parcel[0]) + str('&&p_language=de')
  556.             post_session = requests.session()
  557.             post_parcel_data = post_session.get(post_link)
  558.             post_parcel_data_enc = post_parcel_data.content
  559.             status_code_data = re.findall('<span class="fvEventCode">[0-9]{1,2} <\/span>', str(post_parcel_data_enc))
  560.             status_code = re.sub('[^0-9]', '', str(status_code_data))
  561.             if status_code == '2':
  562.                 statement_status2 = """UPDATE dbo.History SET Movement='Ausgang', Status='Packet aufgegeben' WHERE Pk_ID_History=%s""" % parcel[1]
  563.                 cursor = conn.cursor()
  564.                 cursor.execute(statement_status2)
  565.                 conn.commit()
  566.             elif status_code == '288':
  567.                 statement_status88 = """UPDATE dbo.History Movement='Ausgang', SET Status='sortiert und weiterge.' WHERE Pk_ID_History=%s""" % parcel[1]
  568.                 cursor = conn.cursor()
  569.                 cursor.execute(statement_status88)
  570.                 conn.commit()
  571.             elif status_code == '28812':
  572.                 statement_status12 = """UPDATE dbo.History SET Movement='Ausgang', Status='sortiert für Zustellung' WHERE Pk_ID_History=%s""" % parcel[1]
  573.                 cursor = conn.cursor()
  574.                 cursor.execute(statement_status12)
  575.                 conn.commit()
  576.             elif status_code == '2881210':
  577.                 statement_status10 = """UPDATE dbo.History SET Movement='Ausgang', Status='ankunft abhol und Zust.' WHERE Pk_ID_History=%s""" % parcel[1]
  578.                 cursor = conn.cursor()
  579.                 cursor.execute(statement_status10)
  580.                 conn.commit()
  581.             elif status_code == '288121040':
  582.                 statement_status40 = """UPDATE dbo.History SET Movement='Ausgang', Status='Zugestellt' WHERE Pk_ID_History=%s""" % parcel[1]
  583.                 cursor = conn.cursor()
  584.                 cursor.execute(statement_status40)
  585.                 conn.commit()
  586.             else:
  587.                 statement_status_errors = """UPDATE dbo.History SET Movement='Ausgang', Status='%s' WHERE Pk_ID_History=%s""" % (post_link, parcel[1])
  588.                 cursor = conn.cursor()
  589.                 cursor.execute(statement_status_errors)
  590.                 conn.commit()
  591.         except requests.exceptions.RequestException as e:
  592.             flash(e)
  593.  
  594.     conn.close()
  595.  
  596.  
  597. @atexit.register
  598. def goodbye():
  599.     print("GOODBYE")
  600.  
  601. if __name__ == "__main__":
  602.     app.secret_key = os.urandom(12)
  603.     app.run(host='0.0.0.0', port=80, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement