Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Dec 23, 2024
1 parent f7c38ee commit ce5fd3c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions geonames/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def post(self):

if file and file.filename.endswith(".tsv"):
# Save the file to the uploads directory
file_path = os.path.join(app.config["UPLOAD_FOLDER"], file.filename)
file_path = os.path.normpath(os.path.join(app.config["UPLOAD_FOLDER"], file.filename))
if not file_path.startswith(app.config["UPLOAD_FOLDER"]):
return {"error": "Invalid file path."}, 400
file.save(file_path)

# Insert data from the TSV file into the database
Expand All @@ -152,4 +154,5 @@ def post(self):
init_db()
config = yaml.safe_load(open("config/default.yaml", encoding="utf-8"))
app.config["insdc_country_code_mapping"] = config.get("insdc_country_code_mapping", {})
app.run(debug=True)
debug_mode = os.getenv("FLASK_DEBUG", "False").lower() in ("true", "1", "t")
app.run(debug=debug_mode)

0 comments on commit ce5fd3c

Please sign in to comment.