moathA commited on
Commit
5dbd6fa
·
verified ·
1 Parent(s): da2d53f

Upload folder using huggingface_hub

Browse files
app.py CHANGED
@@ -41,6 +41,14 @@ def load_user(user_id):
41
 
42
  # --- Routes ---
43
 
 
 
 
 
 
 
 
 
44
  @app.route('/')
45
  def home():
46
  return render_template('new 1.html')
@@ -176,6 +184,7 @@ def signup():
176
  if request.method == 'POST':
177
  email = request.form.get('email')
178
  name = request.form.get('name')
 
179
  password = request.form.get('password')
180
 
181
  user = User.query.filter_by(email=email).first()
@@ -184,15 +193,26 @@ def signup():
184
  flash('Email address already exists')
185
  return redirect(url_for('signup'))
186
 
187
- new_user = User(email=email, name=name, password=generate_password_hash(password, method='scrypt'))
188
-
189
- db.session.add(new_user)
190
- db.session.commit()
191
-
192
- # Log user in immediately after signup
193
- login_user(new_user)
194
-
195
- return redirect(url_for('questionnaire'))
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  return render_template('signup.html')
198
 
 
41
 
42
  # --- Routes ---
43
 
44
+ @app.route('/sw.js')
45
+ def serve_sw():
46
+ return app.send_static_file('sw.js')
47
+
48
+ @app.route('/manifest.json')
49
+ def serve_manifest():
50
+ return app.send_static_file('manifest.json')
51
+
52
  @app.route('/')
53
  def home():
54
  return render_template('new 1.html')
 
184
  if request.method == 'POST':
185
  email = request.form.get('email')
186
  name = request.form.get('name')
187
+ username = request.form.get('username')
188
  password = request.form.get('password')
189
 
190
  user = User.query.filter_by(email=email).first()
 
193
  flash('Email address already exists')
194
  return redirect(url_for('signup'))
195
 
196
+ try:
197
+ new_user = User(
198
+ email=email,
199
+ name=name,
200
+ username=username,
201
+ password=generate_password_hash(password, method='scrypt')
202
+ )
203
+
204
+ db.session.add(new_user)
205
+ db.session.commit()
206
+
207
+ # Log user in immediately after signup
208
+ login_user(new_user)
209
+ return redirect(url_for('questionnaire'))
210
+
211
+ except Exception as e:
212
+ db.session.rollback()
213
+ app.logger.error(f"Signup error: {e}")
214
+ flash('An error occurred during sign up. Please try again.')
215
+ return redirect(url_for('signup'))
216
 
217
  return render_template('signup.html')
218
 
models.py CHANGED
@@ -8,6 +8,7 @@ class User(UserMixin, db.Model):
8
  email = db.Column(db.String(100), unique=True)
9
  password = db.Column(db.String(255))
10
  name = db.Column(db.String(1000))
 
11
  trip_count = db.Column(db.Integer, default=0)
12
 
13
  # You can add more fields like profile_pic, etc.
 
8
  email = db.Column(db.String(100), unique=True)
9
  password = db.Column(db.String(255))
10
  name = db.Column(db.String(1000))
11
+ username = db.Column(db.String(100), unique=True)
12
  trip_count = db.Column(db.Integer, default=0)
13
 
14
  # You can add more fields like profile_pic, etc.
patch_templates.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+
4
+ pwa_tags = """
5
+ <!-- PWA Setup -->
6
+ <link rel="manifest" href="/manifest.json">
7
+ <meta name="theme-color" content="#d4af37">
8
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
9
+ <script>
10
+ if ('serviceWorker' in navigator) {
11
+ window.addEventListener('load', () => {
12
+ navigator.serviceWorker.register('/sw.js')
13
+ .then(reg => console.log('ServiceWorker registered'))
14
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
15
+ });
16
+ }
17
+ </script>
18
+ </head>
19
+ """
20
+
21
+ templates_dir = os.path.join(os.path.dirname(__file__), 'templates')
22
+ for filepath in glob.glob(os.path.join(templates_dir, '*.html')):
23
+ with open(filepath, 'r', encoding='utf-8') as f:
24
+ content = f.read()
25
+
26
+ # Only replace if not already added
27
+ if "rel=\"manifest\"" not in content and "</head>" in content:
28
+ content = content.replace("</head>", pwa_tags)
29
+ with open(filepath, 'w', encoding='utf-8') as f:
30
+ f.write(content)
31
+ print(f"Patched {os.path.basename(filepath)}")
reproduce_issue.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ def reproduce_signup():
4
+ import time
5
+ ts = int(time.time())
6
+ url = "http://127.0.0.1:5000/signup"
7
+ data = {
8
+ "name": "Repro User",
9
+ "email": f"repro_{ts}@example.com",
10
+ "password": "password123",
11
+ "username": f"reprouser_{ts}"
12
+ }
13
+
14
+ print(f"Sending POST to {url} with data: {data}")
15
+ response = requests.post(url, data=data, allow_redirects=False)
16
+
17
+ print(f"Status Code: {response.status_code}")
18
+ print(f"Headers: {response.headers}")
19
+
20
+ if 'Location' in response.headers:
21
+ print(f"Redirecting to: {response.headers['Location']}")
22
+ else:
23
+ print("No redirect found. Content length:", len(response.text))
24
+ # Look for flash messages in the response HTML if it didn't redirect
25
+ if "Email address already exists" in response.text:
26
+ print("Flash message found: Email address already exists")
27
+ else:
28
+ print("HTML snippet (last 500 chars):")
29
+ print(response.text[-500:])
30
+
31
+ if __name__ == "__main__":
32
+ reproduce_signup()
static/manifest.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Tarist",
3
+ "short_name": "Tarist",
4
+ "description": "Egypt's Premier Travel Experience & Guide",
5
+ "start_url": "/",
6
+ "display": "standalone",
7
+ "background_color": "#0d1b2a",
8
+ "theme_color": "#d4af37",
9
+ "icons": [
10
+ {
11
+ "src": "/static/images/hero2.jpg",
12
+ "sizes": "192x192",
13
+ "type": "image/jpeg"
14
+ },
15
+ {
16
+ "src": "/static/images/hero2.jpg",
17
+ "sizes": "512x512",
18
+ "type": "image/jpeg"
19
+ }
20
+ ]
21
+ }
static/sw.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const CACHE_NAME = 'tarist-cache-v1';
2
+ const urlsToCache = [
3
+ '/',
4
+ '/explore',
5
+ '/static/css/styles-1.css',
6
+ '/static/manifest.json'
7
+ ];
8
+
9
+ self.addEventListener('install', event => {
10
+ event.waitUntil(
11
+ caches.open(CACHE_NAME)
12
+ .then(cache => {
13
+ console.log('Opened cache');
14
+ return cache.addAll(urlsToCache);
15
+ })
16
+ );
17
+ });
18
+
19
+ self.addEventListener('fetch', event => {
20
+ event.respondWith(
21
+ caches.match(event.request)
22
+ .then(response => {
23
+ // Cache hit - return response
24
+ if (response) {
25
+ return response;
26
+ }
27
+ return fetch(event.request).catch(() => {
28
+ // Optional: return a fallback page if network fails
29
+ });
30
+ }
31
+ )
32
+ );
33
+ });
templates/about.html CHANGED
@@ -9,8 +9,23 @@
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/about_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
 
 
14
  <body>
15
  <!-- Navbar -->
16
  <nav class="navbar-landingpage">
 
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/about_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
12
+
13
+ <!-- PWA Setup -->
14
+ <link rel="manifest" href="/manifest.json">
15
+ <meta name="theme-color" content="#d4af37">
16
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
17
+ <script>
18
+ if ('serviceWorker' in navigator) {
19
+ window.addEventListener('load', () => {
20
+ navigator.serviceWorker.register('/sw.js')
21
+ .then(reg => console.log('ServiceWorker registered'))
22
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
23
+ });
24
+ }
25
+ </script>
26
  </head>
27
 
28
+
29
  <body>
30
  <!-- Navbar -->
31
  <nav class="navbar-landingpage">
templates/dashboard.html CHANGED
@@ -74,8 +74,23 @@
74
  }
75
  </style>
76
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </head>
78
 
 
79
  <body>
80
  <!-- Navbar -->
81
  <nav class="navbar-landingpage">
 
74
  }
75
  </style>
76
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
77
+
78
+ <!-- PWA Setup -->
79
+ <link rel="manifest" href="/manifest.json">
80
+ <meta name="theme-color" content="#d4af37">
81
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
82
+ <script>
83
+ if ('serviceWorker' in navigator) {
84
+ window.addEventListener('load', () => {
85
+ navigator.serviceWorker.register('/sw.js')
86
+ .then(reg => console.log('ServiceWorker registered'))
87
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
88
+ });
89
+ }
90
+ </script>
91
  </head>
92
 
93
+
94
  <body>
95
  <!-- Navbar -->
96
  <nav class="navbar-landingpage">
templates/experience_details.html CHANGED
@@ -9,8 +9,23 @@
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Navbar -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/experiencedetails_clean.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
 
 
14
  <body>
15
  <!-- Navbar -->
16
  <nav class="navbar-landingpage">
 
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Navbar -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/experiencedetails_clean.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
12
+
13
+ <!-- PWA Setup -->
14
+ <link rel="manifest" href="/manifest.json">
15
+ <meta name="theme-color" content="#d4af37">
16
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
17
+ <script>
18
+ if ('serviceWorker' in navigator) {
19
+ window.addEventListener('load', () => {
20
+ navigator.serviceWorker.register('/sw.js')
21
+ .then(reg => console.log('ServiceWorker registered'))
22
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
23
+ });
24
+ }
25
+ </script>
26
  </head>
27
 
28
+
29
  <body>
30
  <!-- Navbar -->
31
  <nav class="navbar-landingpage">
templates/explore.html CHANGED
@@ -41,8 +41,23 @@
41
  }
42
  });
43
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  </head>
45
 
 
46
  <body>
47
  <!-- Navbar -->
48
  <nav class="navbar-landingpage">
 
41
  }
42
  });
43
  </script>
44
+
45
+ <!-- PWA Setup -->
46
+ <link rel="manifest" href="/manifest.json">
47
+ <meta name="theme-color" content="#d4af37">
48
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
49
+ <script>
50
+ if ('serviceWorker' in navigator) {
51
+ window.addEventListener('load', () => {
52
+ navigator.serviceWorker.register('/sw.js')
53
+ .then(reg => console.log('ServiceWorker registered'))
54
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
55
+ });
56
+ }
57
+ </script>
58
  </head>
59
 
60
+
61
  <body>
62
  <!-- Navbar -->
63
  <nav class="navbar-landingpage">
templates/how_it_works.html CHANGED
@@ -9,8 +9,23 @@
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/how_it_works_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
 
 
14
  <body>
15
  <!-- Navbar -->
16
  <nav class="navbar-landingpage">
 
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/how_it_works_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
12
+
13
+ <!-- PWA Setup -->
14
+ <link rel="manifest" href="/manifest.json">
15
+ <meta name="theme-color" content="#d4af37">
16
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
17
+ <script>
18
+ if ('serviceWorker' in navigator) {
19
+ window.addEventListener('load', () => {
20
+ navigator.serviceWorker.register('/sw.js')
21
+ .then(reg => console.log('ServiceWorker registered'))
22
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
23
+ });
24
+ }
25
+ </script>
26
  </head>
27
 
28
+
29
  <body>
30
  <!-- Navbar -->
31
  <nav class="navbar-landingpage">
templates/login.html CHANGED
@@ -9,8 +9,23 @@
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Reuse Navbar styles -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/login_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
 
 
14
  <body>
15
  <!-- Navbar Removed -->
16
 
 
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Reuse Navbar styles -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/login_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
12
+
13
+ <!-- PWA Setup -->
14
+ <link rel="manifest" href="/manifest.json">
15
+ <meta name="theme-color" content="#d4af37">
16
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
17
+ <script>
18
+ if ('serviceWorker' in navigator) {
19
+ window.addEventListener('load', () => {
20
+ navigator.serviceWorker.register('/sw.js')
21
+ .then(reg => console.log('ServiceWorker registered'))
22
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
23
+ });
24
+ }
25
+ </script>
26
  </head>
27
 
28
+
29
  <body>
30
  <!-- Navbar Removed -->
31
 
templates/new 1.1.html CHANGED
@@ -4,6 +4,21 @@
4
  <meta charset="UTF-8">
5
  <title>tarist</title>
6
  <link rel="stylesheet" href="C:\Users\Abd Elrahman\Desktop\Tarist\static">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
 
 
9
  </html>
 
4
  <meta charset="UTF-8">
5
  <title>tarist</title>
6
  <link rel="stylesheet" href="C:\Users\Abd Elrahman\Desktop\Tarist\static">
7
+
8
+ <!-- PWA Setup -->
9
+ <link rel="manifest" href="/manifest.json">
10
+ <meta name="theme-color" content="#d4af37">
11
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
12
+ <script>
13
+ if ('serviceWorker' in navigator) {
14
+ window.addEventListener('load', () => {
15
+ navigator.serviceWorker.register('/sw.js')
16
+ .then(reg => console.log('ServiceWorker registered'))
17
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
18
+ });
19
+ }
20
+ </script>
21
  </head>
22
 
23
+
24
  </html>
templates/new 1.html CHANGED
@@ -12,8 +12,23 @@
12
  <!-- Local Stylesheet -->
13
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
14
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  </head>
16
 
 
17
  <body>
18
  <!-- Navbar -->
19
  <nav class="navbar-landingpage">
 
12
  <!-- Local Stylesheet -->
13
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}">
14
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
15
+
16
+ <!-- PWA Setup -->
17
+ <link rel="manifest" href="/manifest.json">
18
+ <meta name="theme-color" content="#d4af37">
19
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
20
+ <script>
21
+ if ('serviceWorker' in navigator) {
22
+ window.addEventListener('load', () => {
23
+ navigator.serviceWorker.register('/sw.js')
24
+ .then(reg => console.log('ServiceWorker registered'))
25
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
26
+ });
27
+ }
28
+ </script>
29
  </head>
30
 
31
+
32
  <body>
33
  <!-- Navbar -->
34
  <nav class="navbar-landingpage">
templates/questionnaire.html CHANGED
@@ -7,8 +7,23 @@
7
  <title>Tarist - Personalize Your Trip</title>
8
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap" rel="stylesheet">
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/questionnaire.css') }}">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </head>
11
 
 
12
  <body>
13
  <div class="q-container">
14
  <!-- Skip Button -->
 
7
  <title>Tarist - Personalize Your Trip</title>
8
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap" rel="stylesheet">
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/questionnaire.css') }}">
10
+
11
+ <!-- PWA Setup -->
12
+ <link rel="manifest" href="/manifest.json">
13
+ <meta name="theme-color" content="#d4af37">
14
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
15
+ <script>
16
+ if ('serviceWorker' in navigator) {
17
+ window.addEventListener('load', () => {
18
+ navigator.serviceWorker.register('/sw.js')
19
+ .then(reg => console.log('ServiceWorker registered'))
20
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
21
+ });
22
+ }
23
+ </script>
24
  </head>
25
 
26
+
27
  <body>
28
  <div class="q-container">
29
  <!-- Skip Button -->
templates/signup.html CHANGED
@@ -9,8 +9,23 @@
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Reuse Navbar styles -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/login_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
 
 
14
  <body>
15
  <!-- Navbar Removed -->
16
 
 
9
  <link rel="stylesheet" href="{{ url_for('static', filename='css/styles-1.css') }}"> <!-- Reuse Navbar styles -->
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/login_style.css') }}">
11
  <script src="{{ url_for('static', filename='js/auth.js') }}" defer></script>
12
+
13
+ <!-- PWA Setup -->
14
+ <link rel="manifest" href="/manifest.json">
15
+ <meta name="theme-color" content="#d4af37">
16
+ <link rel="apple-touch-icon" href="/static/images/hero2.jpg">
17
+ <script>
18
+ if ('serviceWorker' in navigator) {
19
+ window.addEventListener('load', () => {
20
+ navigator.serviceWorker.register('/sw.js')
21
+ .then(reg => console.log('ServiceWorker registered'))
22
+ .catch(err => console.log('ServiceWorker registration failed: ', err));
23
+ });
24
+ }
25
+ </script>
26
  </head>
27
 
28
+
29
  <body>
30
  <!-- Navbar Removed -->
31