Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,12 @@ def SaveResult(text, outputfileName):
|
|
36 |
def store_message(name: str, message: str, outputfileName: str):
|
37 |
basedir = os.path.dirname(__file__)
|
38 |
savePath = outputfileName
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
if name and message:
|
40 |
with open(savePath, "a") as csvfile:
|
41 |
writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
|
|
|
36 |
def store_message(name: str, message: str, outputfileName: str):
|
37 |
basedir = os.path.dirname(__file__)
|
38 |
savePath = outputfileName
|
39 |
+
|
40 |
+
file_exists = exists(savePath)
|
41 |
+
if (file_exists==False):
|
42 |
+
with open(outputfileName, "w") as f: #write
|
43 |
+
f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
|
44 |
+
|
45 |
if name and message:
|
46 |
with open(savePath, "a") as csvfile:
|
47 |
writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
|