Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
48a275b
Update main.py
ScottyHong Oct 12, 2024
892823a
dd
ScottyHong Oct 12, 2024
1a944d9
New
ScottyHong Oct 12, 2024
3fbf720
m
ScottyHong Oct 12, 2024
b8fc41f
n/a changes
jasonph314 Oct 12, 2024
a64cf06
Merge pull request #3 from kyleenax/kyleena-new
ScottyHong Oct 12, 2024
4584e17
renamed main.py to sleep_and_task.py
jasonph314 Oct 12, 2024
ab83b17
d
ScottyHong Oct 12, 2024
67a95c2
Delete style.css
jasonph314 Oct 12, 2024
6d2976f
Merge pull request #4 from kyleenax/Jason2
ScottyHong Oct 12, 2024
b71e914
Update ky.py
ScottyHong Oct 12, 2024
84f7a86
Main type shit
ScottyHong Oct 12, 2024
619e9eb
empty
jasonph314 Oct 12, 2024
932110e
11
ScottyHong Oct 12, 2024
8e4e14d
eqwwq
jasonph314 Oct 13, 2024
1c602c8
fixed welcome start
jasonph314 Oct 13, 2024
11a9e32
122
ScottyHong Oct 13, 2024
91d2faa
progress bar
thekavishshah Oct 13, 2024
f85896b
Update main.py
thekavishshah Oct 13, 2024
36c0b34
1
jasonph314 Oct 13, 2024
e2ec980
Update tasks.html
ScottyHong Oct 13, 2024
155c0d9
Update schedule.html
ScottyHong Oct 13, 2024
9192c57
Update schedule.html
ScottyHong Oct 13, 2024
4d77b82
no sleep checkbox
jasonph314 Oct 13, 2024
cdff6b0
Update main.py
thekavishshah Oct 13, 2024
312d9dc
Update sleep.html
thekavishshah Oct 13, 2024
0932c05
Update main.py
thekavishshah Oct 13, 2024
2b7829b
Update schedule.html
thekavishshah Oct 13, 2024
ed9c896
front end push
kyleenax Oct 13, 2024
f48265c
changes
kyleenax Oct 13, 2024
0e1f967
Update schedule.html
jasonph314 Oct 13, 2024
48cd52f
Merge branch 'Development' of https://github.com/kyleenax/sleep-soon-…
jasonph314 Oct 13, 2024
0ef0e8e
Create sleep.html
kyleenax Oct 13, 2024
fd633eb
Update main.py
ScottyHong Oct 13, 2024
cb14c46
sleep to bottom a fucking gain
jasonph314 Oct 13, 2024
127b3e7
Update main.py
ScottyHong Oct 13, 2024
db3ae6b
Last Push
ScottyHong Oct 13, 2024
64fd452
Final
ScottyHong Oct 13, 2024
b4762ef
done
jasonph314 Oct 13, 2024
8bdf0ed
time stuff
jasonph314 Oct 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
203 changes: 198 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,207 @@
from flask import Flask, render_template
from flask import Flask, render_template, request, redirect, url_for, session

app = Flask(__name__)
app.secret_key = 'your_secret_key' # Needed for session management

# Welcome route (first page where user can start the process)
@app.route('/')
def welcome():
return render_template('welcome.html') # Render the welcome page
return render_template('welcome.html')

# Route to enter sleep hours
@app.route('/sleep')
def sleep():
return render_template('sleep.html')

# Route to handle sleep hours submission and move to task entry
# @app.route('/tasks', methods=['POST'])
# def tasks():
# sleep_hours = request.form.get('sleep')
# start_time = request.form.get('start_time')

# # Validate sleep hours (must be a non-negative number)
# if sleep_hours and sleep_hours.isdigit() and int(sleep_hours) >= 0:
# session['sleep_hours'] = int(sleep_hours) # Store sleep hours in session

# # Validate start time format (should be a valid time in HH:MM format)
# if start_time:
# try:
# hours, minutes = map(int, start_time.split(':'))
# if 0 <= hours < 24 and 0 <= minutes < 60:
# session['start_time'] = start_time # Store start time in session
# return render_template('tasks.html') # Render the task entry page
# else:
# return "Invalid start time. Please enter a valid time in HH:MM format.", 400
# except ValueError:
# return "Invalid start time. Please enter a valid time in HH:MM format.", 400
# else:
# return "Start time is required.", 400
# else:
# return "Please enter a valid sleep duration.", 400
@app.route('/tasks', methods=['POST'])
def tasks():
sleep_hours = request.form.get('sleep')
start_time = request.form.get('start_time')

# Validate sleep hours (must be between 6 and 12 hours)
if sleep_hours and sleep_hours.isdigit():
sleep_hours = int(sleep_hours)
if 6 <= sleep_hours <= 12:
session['sleep_hours'] = sleep_hours # Store sleep hours in session

# Validate start time format (should be a valid time in HH:MM format)
if start_time:
try:
hours, minutes = map(int, start_time.split(':'))
if 0 <= hours < 24 and 0 <= minutes < 60:
session['start_time'] = start_time # Store start time in session
return render_template('tasks.html') # Render the task entry page
else:
return "Invalid start time. Please enter a valid time in HH:MM format.", 400
except ValueError:
return "Invalid start time. Please enter a valid time in HH:MM format.", 400
else:
return "Start time is required.", 400
else:
# Encourage a healthy sleep duration between 6 and 12 hours
return render_template('sleep-shame.html', message="Please enter a healthy sleep duration between 6 and 12 hours.")
else:
return render_template('sleep-shame.html', message="Please enter a valid sleep duration between 6 and 12 hours.")
# @app.route('/tasks', methods=['POST']) KYLEENAAAASSS
# def tasks():
# sleep_hours = request.form.get('sleep') # Retrieve sleep hours from form
# start_time = request.form.get('start_time') # Retrieve start time from form

# try:
# # Convert sleep hours to a float to handle decimal entries
# sleep_hours = float(sleep_hours)

# # Check if sleep hours are within the valid range
# if sleep_hours > 11:
# return render_template('sleep.html', error="Sleep hours cannot exceed 12. Please enter a valid value.")
# if sleep_hours < 7:
# return render_template('sleep.html', error="Sleep hours cannot be below 6. Please enter a valid value.")

# # Store valid sleep hours in the session
# session['sleep_hours'] = sleep_hours

# # Validate start time format
# if start_time:
# try:
# hours, minutes = map(int, start_time.split(':'))
# if 0 <= hours < 24 and 0 <= minutes < 60:
# session['start_time'] = start_time # Store start time in session
# return redirect(url_for('task_entry')) # Correctly redirect to the task entry page
# else:
# return render_template('sleep.html', error="Invalid start time. Please enter a valid time in HH:MM format.")
# except ValueError:
# return render_template('sleep.html', error="Invalid start time. Please enter a valid time in HH:MM format.")
# else:
# return render_template('sleep.html', error="Start time is required.")

# except ValueError:
# return render_template('sleep.html', error="Invalid input for sleep hours. Please enter a number.")
import random
@app.route('/task_entry')
def task_entry():
# Clear session values to reset inputs
session.pop('sleep_hours', None)
session.pop('start_time', None)
return render_template('tasks.html') # Ensure you create this template
@app.route('/generate_schedule', methods=['POST'])
def generate_schedule():
try:
sleep_hours = session.get('sleep_hours', 0) # Default to 0 if not set
start_time = session.get('start_time', '00:00') # Default to '00:00' if not set
tasks = []
total_duration = 0 # We calculate total duration of tasks first

# List of mental health activities
activities = ['meditate', 'yoga', 'walk', 'eat', 'drink water', 'nap', 'HIIT']

# Collect task inputs
for i in range(1, 10): # Assuming a max of 9 tasks
task_name = request.form.get(f'task{i}')
task_duration = request.form.get(f'task{i}_duration')

if task_name and task_duration:
try:
task_duration = int(task_duration)
if task_duration < 0:
return "Durations must be positive.", 400
tasks.append((task_name, task_duration))
total_duration += task_duration
except ValueError:
return "Invalid task duration. Please enter a valid number.", 400

# Include breaks between tasks, but not after the last one
total_break_time = (len(tasks) - 1) * 0.25 # 15-minute break between tasks
total_duration += total_break_time

# Check if the total task and break time exceeds the time before sleep (9:00 PM)
# From the start time until 21:00 (9:00 PM), we have this much time available for tasks
max_available_time_for_tasks = (21 - int(start_time.split(':')[0])) # Time until 9 PM

if total_duration > max_available_time_for_tasks:
return "The total duration of tasks and breaks exceeds the time available before sleep at 9:00 PM.", 400

# Generate the schedule with tasks before sleep
schedule = []
start_hour, start_minute = map(int, start_time.split(':'))
current_time_hour = start_hour
current_time_minute = start_minute

# Add tasks to the schedule, including 15-minute breaks with mental health suggestions
for index, (task_name, task_duration) in enumerate(tasks):
task_end_hour = (current_time_hour + task_duration) % 24
schedule.append({
"name": task_name,
"start": f"{current_time_hour:02}:{current_time_minute:02}",
"end": f"{task_end_hour:02}:{current_time_minute:02}",
"duration": task_duration
})
current_time_hour = task_end_hour

# Add 15-minute break, except for the last task
if index < len(tasks) - 1:
# current_time_minute += 15
if current_time_minute >= 60:
current_time_hour = (current_time_hour + 1) % 24
current_time_minute %= 60

# Choose a random mental health activity for the break
activity = random.choice(activities)

schedule.append({
"name": f"Break - {activity.capitalize()}",
"start": f"{current_time_hour:02}:{current_time_minute:02}",
"end": f"{current_time_hour:02}:{(current_time_minute + 15) % 60:02}",
"duration": 0.25
})

current_time_minute = (current_time_minute + 15) % 60
if current_time_minute >= 60:
current_time_hour = (current_time_hour + 1) % 24
current_time_minute %= 60

# Force sleep time between 9 PM and 11 PM
sleep_start_hour = 21 # Sleep starts at 9 PM (21:00)
sleep_end_hour = (sleep_start_hour + sleep_hours) % 24
if sleep_end_hour > 23:
return "Sleep must end before 11:00 PM.", 400 # Sleep cannot extend beyond 11 PM

schedule.append({
"name": "Sleep",
"start": f"{sleep_start_hour:02}:00",
"end": f"{sleep_end_hour:02}:00",
"duration": sleep_hours
})

return render_template('schedule.html', schedule=schedule)

except ValueError:
return "Invalid input. Please enter valid task durations.", 400

@app.route('/next')
def next_page():
return render_template('next_page.html') # Render the next page (e.g., to-do list form)

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
32 changes: 32 additions & 0 deletions static/css/goal_sleep.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
body {
background-color: #f7f9fc; /* Light background color */
font-family: 'Poppins', sans-serif; /* Use the selected font */
}

.card {
border-radius: 15px; /* Rounded corners */
background-color: #ffffff; /* White background for card */
}

h1 {
color: #333333; /* Dark text for title */
margin-bottom: 20px; /* Space below the title */
}

input[type="number"] {
border-radius: 5px; /* Rounded corners for input */
}

button {
border-radius: 5px; /* Rounded corners for button */
padding: 10px; /* Space inside button */
}

.btn-primary {
background-color: rgb(37,41,178); /* Custom button color */
border: none; /* No border */
}

.btn-primary:hover {
background-color: #0b1d30; /* Darker shade on hover */
}
103 changes: 48 additions & 55 deletions static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
/* Set the body style */
body {
background: url('../images/background.png') repeat; /* Background image */
animation: moveBackground 60s linear infinite; /* Animation for moving background */
color: rgb(255, 255, 255); /* White text */
display: flex; /* Use Flexbox for centering */
flex-direction: column; /* Stack elements vertically */
justify-content: center; /* Center vertically */
align-items: center; /* Center horizontally */
height: 100vh; /* Full viewport height */
margin: 0; /* Remove default margin */
font-family: Verdana, Geneva, Tahoma, sans-serif; /* Font style */
}

/* Animation to move background */
@keyframes moveBackground {
from {
Expand All @@ -22,59 +8,66 @@ body {
}
}

/* Set the heading style for the arched title */
#curved-title {
display: flex; /* Use flexbox for alignment */
justify-content: center; /* Center the title */
font-size: 12em; /* Adjust font size */
margin-bottom: 20px; /* Space between title and image */
position: relative; /* For absolute positioning of spans */
color: rgb(32, 34, 56); /* Set text color to white */
text-transform: uppercase; /* Make text all caps */
text-shadow: 0 2px 0 rgba(143, 128, 128, 0.5),
0 4px 0 rgba(49, 46, 46, 0.4),
0 6px 0 rgba(4, 4, 4, 0.3); /* Add text shadow */
/* Background container with animation */
.background-container {
background-image: url('../images/background.png'); /* Adjusted path for the background image */
background-size: cover; /* Ensure the background covers the entire area */
background-position: center; /* Center the background */
animation: moveBackground 15s linear infinite; /* Smooth animation, infinite looping */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh; /* Full height of the viewport */
overflow: hidden; /* Hide any overflow */
}

/* Apply rotation for each letter */
#curved-title span {
display: inline-block; /* Allow rotation */
/* Image container for holding all three images */
.image-container {
display: flex; /* Align images in a row */
justify-content: center; /* Center images horizontally */
align-items: center; /* Center images vertically */
width: 100%; /* Full width for container */
}

/* Individual rotation for each letter to create an arch effect */
#curved-title span:nth-child(1) { transform: rotate(-20deg); }
#curved-title span:nth-child(2) { transform: rotate(-15deg); }
#curved-title span:nth-child(3) { transform: rotate(-10deg); }
#curved-title span:nth-child(4) { transform: rotate(-5deg); }
#curved-title span:nth-child(5) { transform: rotate(0deg); }
#curved-title span:nth-child(6) { transform: rotate(5deg); }
#curved-title span:nth-child(7) { transform: rotate(10deg); }
#curved-title span:nth-child(8) { transform: rotate(15deg); }
#curved-title span:nth-child(9) { transform: rotate(20deg); }
#curved-title span:nth-child(10) { transform: rotate(25deg); }
#curved-title span:nth-child(11) { transform: rotate(30deg); }

/* Set the image style */
img {
height: 200px; /* Set desired width for the image */
width: auto; /* Maintain aspect ratio */
width: auto; /* Keep width auto to maintain aspect ratio */
max-width: 30%; /* Set max width to 30% of the parent container */
max-height: 60vh; /* Limit height to 60% of viewport height */
margin: 0 5px; /* Space between images */
object-fit: contain; /* Maintain aspect ratio without stretching */
}

/* Set the button style */
button {
margin-top: 20px; /* Space between image and button */
padding: 15px 25px; /* Button padding */
background-color: rgb(38, 38, 59); /* Button background */
color: #ebebeb; /* Button text color */
border: none; /* Remove border */
border-radius: 5px; /* Rounded corners */
cursor: pointer; /* Pointer on hover */
font-size: 3.5em; /* Button font size */
font-family: Verdana, Geneva, Tahoma, sans-serif;
text-transform: uppercase;
margin-top: 10px; /* Space above button */
padding: 10px 20px; /* Button padding (more space for a rectangular look) */
background-color: rgb(37,41,178); /* Button background */
color: #ebebeb; /* Button text color */
border: none; /* Remove border */
border-radius: 20px; /* Rounded corners (increased for a more rectangular shape) */
cursor: pointer; /* Pointer on hover */
font-size: 1.5em; /* Adjust button font size */
width: 200px; /* Fixed width for the button */
text-align: center; /* Center the button text */
font-family: 'Courier New', Courier, monospace;
font-weight: bold;
}

/* Change button color on hover */
button:hover {
background-color: #e8e8e8; /* Light gray on hover */
background-color: #e8e8e8; /* Light gray on hover */
color: rgb(38, 38, 59); /* Change text color on hover */
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
img {
max-width: 90vw; /* Adjust max width on smaller screens */
max-height: 30vh; /* Limit the height of the image to 30% of the viewport height */
}
button {
font-size: 1.2em; /* Smaller button font size on mobile */
}
}
Binary file modified static/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/books.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/pencil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/welcome_graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/.DS_Store
Binary file not shown.
Loading