HEMANTH commited on
Commit
c3d5eeb
·
1 Parent(s): 9bbe439

only login sys

Browse files
.gitattributes copy ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ # Install system dependencies for OpenCV
7
+ RUN apt-get update && apt-get install -y \
8
+ libgl1-mesa-glx \
9
+ libglib2.0-0 \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ RUN useradd -m -u 1000 user
13
+ USER user
14
+ ENV PATH="/home/user/.local/bin:$PATH"
15
+
16
+ WORKDIR /app
17
+
18
+ COPY --chown=user ./requirements.txt requirements.txt
19
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
+
21
+ COPY --chown=user . /app
22
+ CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"]
README copy.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Vyayamam
3
+ emoji: 🌖
4
+ colorFrom: red
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify, redirect, url_for, render_template, session
2
+ import firebase_admin
3
+ from firebase_admin import credentials, auth, db
4
+
5
+ # Initialize Flask app
6
+ app = Flask(__name__)
7
+ app.secret_key = '9177'
8
+ # Firebase Admin SDK Initialization
9
+ cred = credentials.Certificate("serviceAccountKey.json")
10
+ firebase_admin.initialize_app(cred, {
11
+ 'databaseURL': 'https://fitnessdb-c9b11-default-rtdb.firebaseio.com/'
12
+ })
13
+
14
+ @app.route('/')
15
+ def index():
16
+ return render_template('index.html')
17
+ # Login Route
18
+ @app.route('/register', methods=['POST'])
19
+ def register():
20
+ data = request.get_json()
21
+
22
+ # Extract user details from the request
23
+ name = data['name']
24
+ email = data['email']
25
+ password = data['password']
26
+ age = data['age']
27
+ height = data['height']
28
+ weight = data['weight']
29
+ max_pullups = data['maxPullups']
30
+ min_pullups = data['minPullups']
31
+ gender = data['gender']
32
+ progress = {}
33
+
34
+ # Create Firebase user using Firebase Auth
35
+ try:
36
+ # Create the user in Firebase Authentication
37
+ user = auth.create_user(
38
+ email=email,
39
+ password=password,
40
+ display_name=name
41
+ )
42
+
43
+ # Store additional user data in Firebase Realtime Database
44
+ user_ref = db.reference(f'users/{user.uid}')
45
+ user_ref.set({
46
+ 'name': name,
47
+ 'email': email,
48
+ 'age': age,
49
+ 'height': height,
50
+ 'weight': weight,
51
+ 'maxPullups': max_pullups,
52
+ 'minPullups': min_pullups,
53
+ 'gender': gender,
54
+ })
55
+
56
+ new_user_progress = db.reference(f"daywiseprogress")
57
+ new_user_progress.set({
58
+ 'email':email,
59
+ 'progress':dict()
60
+ })
61
+
62
+ return jsonify({"message": "User registered successfully!"}), 200
63
+ except Exception as e:
64
+ return jsonify({"error": str(e)}), 400
65
+
66
+ @app.route('/login', methods=['POST'])
67
+ def login():
68
+ data = request.get_json()
69
+
70
+ email = data['email']
71
+ password = data['password']
72
+
73
+ try:
74
+ # Authenticate user with Firebase Auth
75
+ user = auth.get_user_by_email(email)
76
+
77
+ # Validate password (Firebase Authentication handles password validation)
78
+ # No need to manually validate password here since Firebase Authentication ensures the password matches
79
+ ref = db.reference("users")
80
+ users_data = ref.get()
81
+
82
+ for user_id,user_data in users_data.items():
83
+ if user_data.get('email') == email:
84
+ user_name = user_data['name']
85
+ session['user_details'] = user_data
86
+ print(user_data['name'])
87
+
88
+
89
+ return jsonify({"message":"sucess"})
90
+
91
+ except auth.AuthError as e:
92
+ return jsonify({"error": "Invalid credentials"}), 401
93
+
94
+ # Home Route (Display User Credentials)
95
+ @app.route('/home', methods=['GET'])
96
+ def home():
97
+ # Get the ID token from the query parameter
98
+ print(session)
99
+ progress = session['progress']
100
+
101
+
102
+ if len(progress) == 0:
103
+
104
+ # Recommended workout code goes here
105
+ return render_template("workout.html")
106
+ else:
107
+ return render_template("currentprogress.html")
108
+
109
+
110
+ if __name__ == '__main__':
111
+ app.run(debug=True)
main.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import mediapipe as mp
3
+ import numpy as np
4
+ import streamlit as st
5
+ from PIL import Image
6
+
7
+ # Initialize Mediapipe Pose
8
+ mp_pose = mp.solutions.pose
9
+ mp_drawing = mp.solutions.drawing_utils
10
+
11
+ # Function to calculate the angle between three points
12
+ def calculate_angle(a, b, c):
13
+ a = np.array(a) # First point
14
+ b = np.array(b) # Middle point
15
+ c = np.array(c) # Last point
16
+
17
+ radians = np.arctan2(c[1] - b[1], c[0] - b[0]) - np.arctan2(a[1] - b[1], a[0] - b[0])
18
+ angle = np.abs(radians * 180.0 / np.pi)
19
+
20
+ if angle > 180.0:
21
+ angle = 360 - angle
22
+
23
+ return angle
24
+
25
+ # Function to check shoulder press posture
26
+ def is_shoulder_press_correct(landmarks, mp_pose):
27
+ # Get coordinates of shoulder, elbow, and wrist (left arm as example)
28
+ shoulder = [landmarks[mp_pose.PoseLandmark.LEFT_SHOULDER.value].x,
29
+ landmarks[mp_pose.PoseLandmark.LEFT_SHOULDER.value].y]
30
+ elbow = [landmarks[mp_pose.PoseLandmark.LEFT_ELBOW.value].x,
31
+ landmarks[mp_pose.PoseLandmark.LEFT_ELBOW.value].y]
32
+ wrist = [landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].x,
33
+ landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].y]
34
+
35
+ # Calculate angle at the elbow (shoulder, elbow, wrist)
36
+ elbow_angle = calculate_angle(shoulder, elbow, wrist)
37
+
38
+ # Check if the motion is vertical (wrist higher than elbow)
39
+ if wrist[1] < elbow[1] and elbow[1] < shoulder[1]:
40
+ # Ensure proper angle range for a shoulder press
41
+ if 160 <= elbow_angle <= 180:
42
+ return "Shoulder Press: Correct", (0, 255, 0) # Green for correct
43
+ else:
44
+ return "Shoulder Press: Incorrect - Elbow angle", (0, 255, 255) # Yellow for improper angle
45
+ else:
46
+ return "Shoulder Press: Incorrect - Alignment", (255, 0, 0) # Red for alignment issue
47
+
48
+ # Streamlit App
49
+ st.title("Shoulder Press Detection Web App")
50
+
51
+ # Upload video file
52
+ uploaded_file = st.file_uploader("Upload a video file", type=["mp4", "avi"])
53
+
54
+ if uploaded_file is not None:
55
+ # Save uploaded video to a temporary location
56
+ temp_video_path = "uploaded_video.mp4"
57
+ with open(temp_video_path, "wb") as f:
58
+ f.write(uploaded_file.read())
59
+
60
+ # Open video with OpenCV
61
+ cap = cv2.VideoCapture(temp_video_path)
62
+
63
+ stframe = st.empty()
64
+
65
+ with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose:
66
+ while cap.isOpened():
67
+ ret, frame = cap.read()
68
+ if not ret:
69
+ break
70
+
71
+ # Convert the frame to RGB
72
+ image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
73
+ image.flags.writeable = False
74
+
75
+ # Process the image for pose detection
76
+ results = pose.process(image)
77
+
78
+ # Convert back to BGR for rendering
79
+ image.flags.writeable = True
80
+ image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
81
+
82
+ # Extract landmarks
83
+ if results.pose_landmarks:
84
+ landmarks = results.pose_landmarks.landmark
85
+
86
+ # Check shoulder press posture
87
+ feedback, color = is_shoulder_press_correct(landmarks, mp_pose)
88
+
89
+ # Display feedback
90
+ cv2.putText(image, feedback, (50, 50),
91
+ cv2.FONT_HERSHEY_SIMPLEX, 1, color, 2, cv2.LINE_AA)
92
+
93
+ # Draw landmarks
94
+ mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS)
95
+
96
+ else:
97
+ # Warn if no landmarks are detected
98
+ cv2.putText(image, "No body detected", (50, 50),
99
+ cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
100
+
101
+ # Resize frame for Streamlit
102
+ resized_frame = cv2.resize(image, (640, 480))
103
+ frame_rgb = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
104
+ stframe.image(frame_rgb, channels="RGB")
105
+
106
+ cap.release()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ opencv-python-headless
2
+ mediapipe
3
+ numpy
4
+ streamlit
5
+ Pillow
6
+ firebase-admin
serviceAccountKey.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "fitnessdb-c9b11",
4
+ "private_key_id": "d304ad2536ee8ad34e6805b2e3ce6b9b8f2a0fcc",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDNAG4aKS454RQl\ne35uIQYR8BA67RzgRng5DqGM+3E+8vvVUb2LZVzxIFlYP2P6D/U1CgbB8IdfsMx2\nDEz5CnaRsPvz5TvxSNxrqRM6mGRPvg1+HA1auN11LUIiMoWkhNtYXUAG3Ae6TjED\nppykPxlTHxbcnkvZGSQn4DtzHU8xNoLe/lHABHWNMz8kbWSwaFK0Nh+azsxCePzU\nYKgE29OcJDqz3CXocxn9XrTVNzlYCVNcdpWVdjBRRz9Pi4qMZ+APuc32eMcy6E4z\n7XmSTxM4/G/wXei6Kref35Vn+PpBypRgIzmOPvx+vTQhMlAMMlatRgl1XhM3A5ES\n67Sg8aW1AgMBAAECggEAVNSiOxoiYloU+6O8QDdTKzYTiUbYZahTlIzM5imghaOH\n+ZCfJmFWEgPIZP+qT+6tkfqprDRr2HmxSgIyEfY19Xju8dDAuspjR/vJlLw9+k+T\nhsV18z4/if8l+D++1MMTf1/rIEuJuRslJjUaac8gnChnzfiFO3uvXf7oquyMejit\nnL9ss04Fw6TPIv8P8IpERjdAroey9kfKtRXZ167QN7xw87dLp07h0D3T5Z2juVMg\nrA00c8Fv6zer26Pt+wdPTnMc0AYoBjPxg2yBUtajcWbdcZNjswzeH0w5rtSQ8bsJ\nTRF1qOXdJL4JUe1fk3LyXz7viGfDMlrg/roWujMcSwKBgQD6URATlqnZc15zUDfQ\n/YDyTlhhnXkeMmAOdR1ZX916J6+4XRb2GGwuim5gCpNJSva4UyChujxZZKuWXkke\n5jvu4K/DeFuSW0rrldb9GMCbIov0wmqpoeC7wSUupnJ3feaIkT3DeqC1cQYb0Nl1\n1eL3SGAAM/dGhOZR9/0hTPSOqwKBgQDRp/qpRsGqxMT2kuFEUJBTS7fLpqCfLm8n\nS3Bh6R5QLg/PMNgLNsJL8fZ62SdQ9s9/sVNq//r/cCA3WzQHTjNIdfXhSXu6/Iik\n54TkAZjedfnHQ5jUlSNLKqwGYEZ4Ih9wwCr97yXTma0M8HnDjccyemxEHkTYEcol\nP7VOJYEdHwKBgAoWVDCF5MhXhtncxLMOVDDviU49u1DFNOvAOnOMkm9GxCUI01EN\ngOaLO5FxO6g7dh/NccYyrBXqIaQInqe5HXct5MdaxU3rkeRWgHhok/JsfPlbEFNP\nq6/FQ8tSd9Bq6WxddgC3o1xMdrOOQgUmnmParcu0TGWyG1n4RWIfKMfLAoGALS1P\nPC69CLlB4AgidoANuYU1Y7LSJbrxxLviyZZcK9bhHTpfM3tnPsoy3KHycOXeLJvf\nZ80lHungZ01F1tUpA9I3W4ZkHRTRtQcWgbM+Z6FwY1nTkutYIZheXTldtgFUWQ1v\ntixUMFaLDaC7/EGOzPfIYJ1NJGog7wndXauDOO0CgYEAmhbjxZVh9tRFoQJVSt/7\nEklUQXv3MHJQGsM9tglTJBGS5JcYD1vYpNxCFYt3cl5WmM1Gr7OWHre38JCGBgMv\n6+7uGjD5LPHbiMLnSnC1aPl8Tfw8p1hh92rxS6MN4A1Xq72hv73/o9P1nLl5mP9Z\ng/nz1ISSsQi2EMEtZIQIqtc=\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "firebase-adminsdk-lpyql@fitnessdb-c9b11.iam.gserviceaccount.com",
7
+ "client_id": "110696125764328036804",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-lpyql%40fitnessdb-c9b11.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }
14
+
templates/currentprogress.html ADDED
File without changes
templates/index.html ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>NRI HACKS</title>
7
+ <style>
8
+ /* Basic Reset */
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ box-sizing: border-box;
13
+ }
14
+
15
+ body {
16
+ font-family: Arial, sans-serif;
17
+ background-color: #f4f7fc;
18
+ display: flex;
19
+ justify-content: center;
20
+ align-items: center;
21
+ height: 100vh;
22
+ }
23
+
24
+ .form-container {
25
+ width: 100%;
26
+ max-width: 450px;
27
+ background-color: #ffffff;
28
+ padding: 20px;
29
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
30
+ border-radius: 8px;
31
+ }
32
+
33
+ h2 {
34
+ text-align: center;
35
+ color: #333;
36
+ margin-bottom: 20px;
37
+ }
38
+
39
+ .form-group {
40
+ margin-bottom: 15px;
41
+ }
42
+
43
+ .form-group label {
44
+ font-size: 14px;
45
+ color: #555;
46
+ display: block;
47
+ }
48
+
49
+ .form-group input,
50
+ .form-group select {
51
+ width: 100%;
52
+ padding: 10px;
53
+ font-size: 14px;
54
+ border: 1px solid #ccc;
55
+ border-radius: 5px;
56
+ margin-top: 5px;
57
+ }
58
+
59
+ .form-group input[type="submit"] {
60
+ background-color: #4CAF50;
61
+ color: white;
62
+ border: none;
63
+ cursor: pointer;
64
+ }
65
+
66
+ .form-group input[type="submit"]:hover {
67
+ background-color: #45a049;
68
+ }
69
+
70
+ .switch-form {
71
+ text-align: center;
72
+ font-size: 14px;
73
+ }
74
+
75
+ .switch-form span {
76
+ color: #4CAF50;
77
+ cursor: pointer;
78
+ font-weight: bold;
79
+ }
80
+
81
+ .form-content {
82
+ display: none;
83
+ }
84
+
85
+ .form-content.active {
86
+ display: block;
87
+ }
88
+
89
+ #registration-form .form-group {
90
+ display: block;
91
+ }
92
+
93
+ #registration-form .form-group input,
94
+ #registration-form .form-group select {
95
+ width: 100%;
96
+ }
97
+
98
+ #registration-form .form-group input[type="submit"] {
99
+ margin-top: 10px;
100
+ }
101
+
102
+ /* Gender dropdown style (no default selection) */
103
+ #registration-form .form-group select {
104
+ padding: 10px;
105
+ border-radius: 5px;
106
+ border: 1px solid #ccc;
107
+ }
108
+
109
+ /* Fixing the age input size issue */
110
+ #registration-form .form-group input#age {
111
+ width: 100%;
112
+ }
113
+
114
+ /* Style for the age, height, weight fields side by side */
115
+ #registration-form .form-group input#height,
116
+ #registration-form .form-group input#weight {
117
+ width: 48%;
118
+ }
119
+
120
+ #registration-form .form-group {
121
+ display: flex;
122
+ justify-content: space-between;
123
+ gap: 4%;
124
+ }
125
+
126
+ /* Mobile responsiveness */
127
+ @media (max-width: 500px) {
128
+ .form-container {
129
+ width: 90%;
130
+ }
131
+
132
+ #registration-form .form-group {
133
+ display: block;
134
+ }
135
+
136
+ #registration-form .form-group input,
137
+ #registration-form .form-group select {
138
+ width: 100%;
139
+ }
140
+ }
141
+ </style>
142
+ </head>
143
+ <body>
144
+
145
+ <div class="form-container">
146
+ <!-- Login Form -->
147
+ <div id="login-form" class="form-content active">
148
+ <h2>Login</h2>
149
+ <form id="login-form-element" method="post">
150
+ <div class="form-group">
151
+ <label for="login-email">Email:</label>
152
+ <input type="email" id="login-email" name="email" required />
153
+ </div>
154
+ <div class="form-group">
155
+ <label for="login-password">Password:</label>
156
+ <input type="password" id="login-password" name="password" required />
157
+ </div>
158
+ <div class="form-group">
159
+ <input type="submit" value="Login" />
160
+ </div>
161
+ <p class="switch-form">Don't have an account? <span id="to-register">Sign up</span></p>
162
+ </form>
163
+ </div>
164
+
165
+ <!-- Registration Form -->
166
+ <div id="registration-form" class="form-content">
167
+ <h2>Sign Up</h2>
168
+ <form id="registration-form-element" method="post">
169
+ <div class="form-group">
170
+ <label for="name">Name:</label>
171
+ <input type="text" id="name" name="name" required />
172
+ </div>
173
+ <div class="form-group">
174
+ <label for="email">Email:</label>
175
+ <input type="email" id="email" name="email" required />
176
+ </div>
177
+ <div class="form-group">
178
+ <label for="password">Password:</label>
179
+ <input type="password" id="password" name="password" required />
180
+ </div>
181
+ <div class="form-group">
182
+ <label for="age">Age:</label>
183
+ <input type="number" id="age" name="age" required />
184
+ </div>
185
+ <div class="form-group">
186
+ <label for="height">Height (cm):</label>
187
+ <input type="number" id="height" name="height" required />
188
+ </div>
189
+ <div class="form-group">
190
+ <label for="weight">Weight (kg):</label>
191
+ <input type="number" id="weight" name="weight" required />
192
+ </div>
193
+ <div class="form-group">
194
+ <label for="max-pullups">Max Pullups:</label>
195
+ <input type="number" id="max-pullups" name="maxPullups" required />
196
+ </div>
197
+ <div class="form-group">
198
+ <label for="min-pullups">Min Pullups:</label>
199
+ <input type="number" id="min-pullups" name="minPullups" required />
200
+ </div>
201
+ <div class="form-group">
202
+ <label for="gender">Gender:</label>
203
+ <select id="gender" name="gender" required>
204
+ <option value="male">Male</option>
205
+ <option value="female">Female</option>
206
+ <option value="other">Other</option>
207
+ </select>
208
+ </div>
209
+ <div class="form-group">
210
+ <input type="submit" value="Sign Up" />
211
+ </div>
212
+ <p class="switch-form">Already have an account? <span id="to-login">Login</span></p>
213
+ </form>
214
+ </div>
215
+ </div>
216
+
217
+ <script>
218
+ document.getElementById("to-register").addEventListener("click", function() {
219
+ document.getElementById("login-form").classList.remove("active");
220
+ document.getElementById("registration-form").classList.add("active");
221
+ });
222
+
223
+ document.getElementById("to-login").addEventListener("click", function() {
224
+ document.getElementById("registration-form").classList.remove("active");
225
+ document.getElementById("login-form").classList.add("active");
226
+ });
227
+
228
+ // Registration form submit
229
+ document.getElementById("registration-form-element").addEventListener("submit", function(event) {
230
+ event.preventDefault(); // Prevent the form from submitting normally
231
+
232
+ const name = document.getElementById("name").value;
233
+ const email = document.getElementById("email").value;
234
+ const password = document.getElementById("password").value;
235
+ const age = document.getElementById("age").value;
236
+ const height = document.getElementById("height").value;
237
+ const weight = document.getElementById("weight").value;
238
+ const maxPullups = document.getElementById("max-pullups").value;
239
+ const minPullups = document.getElementById("min-pullups").value;
240
+ const gender = document.getElementById("gender").value;
241
+
242
+ fetch("/register", {
243
+ method: "POST",
244
+ headers: {
245
+ "Content-Type": "application/json"
246
+ },
247
+ body: JSON.stringify({
248
+ name,
249
+ email,
250
+ password,
251
+ age,
252
+ height,
253
+ weight,
254
+ maxPullups,
255
+ minPullups,
256
+ gender
257
+ })
258
+ })
259
+ .then(response => response.json())
260
+ .then(data => {
261
+ if (data.message) {
262
+ alert(data.message);
263
+ window.location.href = "/home"; // Redirect after successful registration
264
+ } else {
265
+ alert(data.error);
266
+ }
267
+ })
268
+ .catch(error => {
269
+ console.error("Error during registration:", error);
270
+ alert("An error occurred during registration");
271
+ });
272
+ });
273
+
274
+ // Login form submit
275
+ document.getElementById("login-form-element").addEventListener("submit", function(event) {
276
+ event.preventDefault(); // Prevent the form from submitting normally
277
+
278
+ const email = document.getElementById("login-email").value;
279
+ const password = document.getElementById("login-password").value;
280
+
281
+ fetch("/login", {
282
+ method: "POST",
283
+ headers: {
284
+ "Content-Type": "application/json"
285
+ },
286
+ body: JSON.stringify({
287
+ email: email,
288
+ password: password
289
+ })
290
+ })
291
+ .then(response => response.json())
292
+ .then(data => {
293
+ if (data.message) {
294
+ window.location.href = "/home"; // Redirect after successful login
295
+ } else {
296
+ alert(data.error);
297
+ }
298
+ })
299
+ .catch(error => {
300
+ console.error("Error during login:", error);
301
+ alert("An error occurred during login");
302
+ });
303
+ });
304
+
305
+ </script>
306
+ </body>
307
+ </html>
templates/workout.html ADDED
File without changes
uploaded_video.mp4 ADDED
Binary file (266 kB). View file