Peeble commited on
Commit
466b2c9
·
verified ·
1 Parent(s): 624c2c9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +47 -3
main.py CHANGED
@@ -1,11 +1,18 @@
1
- from flask import Flask, render_template, request
2
 
3
  app = Flask(__name__)
4
 
 
5
  @app.route('/')
6
  def home():
7
  return render_template('index.html')
8
 
 
 
 
 
 
 
9
  @app.route('/upload', methods=['POST'])
10
  def upload_file():
11
  if 'file' not in request.files:
@@ -13,8 +20,45 @@ def upload_file():
13
  file = request.files['file']
14
  if file.filename == '':
15
  return 'No selected file'
16
- # Save the file or process it as needed
17
- return 'File uploaded successfully'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  if __name__ == '__main__':
20
  app.run(debug=True)
 
1
+ from flask import Flask, render_template, request, redirect, url_for
2
 
3
  app = Flask(__name__)
4
 
5
+ # Home page (index.html)
6
  @app.route('/')
7
  def home():
8
  return render_template('index.html')
9
 
10
+ # Upload page
11
+ @app.route('/upload.html')
12
+ def upload_page():
13
+ return render_template('upload.html')
14
+
15
+ # File upload route
16
  @app.route('/upload', methods=['POST'])
17
  def upload_file():
18
  if 'file' not in request.files:
 
20
  file = request.files['file']
21
  if file.filename == '':
22
  return 'No selected file'
23
+ # After upload, redirect to emulator page
24
+ return redirect(url_for('emulator'))
25
+
26
+ # Emulator page with iframe
27
+ @app.route('/emulator.html')
28
+ def emulator():
29
+ return render_template('emulator.html')
30
+
31
+ # 404 Error handler (for no internet or invalid routes)
32
+ @app.errorhandler(404)
33
+ def not_found(error):
34
+ return render_template('error.html'), 404
35
+
36
+ # Android and iOS redirection
37
+ @app.route('/check-device')
38
+ def check_device():
39
+ user_agent = request.headers.get('User-Agent').lower()
40
+
41
+ if "android" in user_agent:
42
+ return redirect('/android')
43
+ elif "iphone" in user_agent or "ipad" in user_agent:
44
+ return redirect('/ios')
45
+ else:
46
+ return redirect('/windows')
47
+
48
+ # Android version (simple redirect)
49
+ @app.route('/android')
50
+ def android():
51
+ return render_template('android.html')
52
+
53
+ # iOS version (simple redirect)
54
+ @app.route('/ios')
55
+ def ios():
56
+ return render_template('ios.html')
57
+
58
+ # Windows version
59
+ @app.route('/windows')
60
+ def windows():
61
+ return render_template('windows.html')
62
 
63
  if __name__ == '__main__':
64
  app.run(debug=True)