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