Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansurf committed May 26, 2024
1 parent f697f55 commit ee219fd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/backend/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,3 @@ def round_decimal(round_list, decimal):
for num in round_list:
rounded_list.append(round(num, decimal))
return rounded_list



38 changes: 24 additions & 14 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import art
import os
import subprocess
import json
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()
load_dotenv(override=True)
website = bool(os.getenv("WEBSITE"))
json_show = bool(os.getenv("JSON"))
print("JSON: ", json_show)

if website == True:
subprocess.Popen(["python", "-m", "http.server", "9000"], cwd="../frontend")
Expand Down Expand Up @@ -64,6 +67,7 @@
if "metric" in args or "m" in args:
ocean["unit"] = "metric"


def gather_data(lat=lat, long=long):
# Calls APIs though python files
ocean_data = api.ocean_information(lat, long, ocean["decimal"], ocean["unit"])
Expand All @@ -90,19 +94,25 @@ def main(lat=lat, long=long):
ocean_data = data[0]
uv_index = data[1]
data_dict = data[2]
print("\n")
if coordinates == "No data":
print("No location found")
if ocean_data == "No data":
print(coordinates)
print("No ocean data at this location.")

if not json_show:
print("\n")
if coordinates == "No data":
print("No location found")
if ocean_data == "No data":
print(coordinates)
print("No ocean data at this location.")
else:
helper.print_location(ocean["city"], ocean["show_city"])
art.print_wave(ocean["show_wave"], ocean["show_large_wave"], ocean["color"])
helper.print_output(ocean)
print("\n")
forecast = api.forecast(lat, long, ocean["decimal"], ocean["forecast_days"])
helper.print_forecast(ocean, forecast)
return data_dict
else:
helper.print_location(ocean["city"], ocean["show_city"])
art.print_wave(ocean["show_wave"], ocean["show_large_wave"], ocean["color"])
helper.print_output(ocean)
print("\n")
forecast = api.forecast(lat, long, ocean["decimal"], ocean["forecast_days"])
helper.print_forecast(ocean, forecast)
return data_dict
json_output = json.dumps(data_dict, indent=4)
print(json_output)
return json_output

main()
2 changes: 1 addition & 1 deletion src/backend/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()
load_dotenv(override=True)

# Email server configuration
SMTP_SERVER = os.getenv("SMTP_SERVER")
Expand Down
2 changes: 1 addition & 1 deletion src/backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()
load_dotenv(override=True)
port_env = int(os.getenv("PORT"))
website = bool(os.getenv("WEBSITE"))

Expand Down

0 comments on commit ee219fd

Please sign in to comment.