Browse Source

better_error_redirect

Francesco 1 year ago
parent
commit
4c089ff022
2 changed files with 6 additions and 3 deletions
  1. 4 1
      app.py
  2. 2 2
      templates/error.html

+ 4 - 1
app.py

@@ -31,7 +31,10 @@ def main():
             outFilePath = appath + outputFolder + outFileName
             inFile = fileFromRequest.read()
             # try to create list of dictionaries keyed by header row
-            parsefromfile(confFilePath, formFields, inFile, outFilePath)
+            try:
+                parsefromfile(confFilePath, formFields, inFile, outFilePath)
+            except:
+                return redirect(url_for('error'))
 
         else:
             # Da completare

+ 2 - 2
templates/error.html

@@ -2,8 +2,8 @@
 <html>
 <body>
 <form method="POST">
-Un mi sembra tu m'abbia dato dati...<br/>
-<input type="submit" value="Artonna">
+<b>DATA ERROR:</b> bad config file, no CSV data, or CSV input file missing required data<br/>
+<input type="submit" value="Back">
 </form>
 </body>
 </html>