|
|
from flask import Flask, render_template, request, redirect, url_for |
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
|
|
|
@app.route('/') |
|
|
def home(): |
|
|
return render_template('index.html') |
|
|
|
|
|
|
|
|
@app.route('/upload.html') |
|
|
def upload_page(): |
|
|
return render_template('upload.html') |
|
|
|
|
|
|
|
|
@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' |
|
|
|
|
|
return redirect(url_for('emulator')) |
|
|
|
|
|
|
|
|
@app.route('/emulator.html') |
|
|
def emulator(): |
|
|
return render_template('emulator.html') |
|
|
|
|
|
|
|
|
@app.errorhandler(404) |
|
|
def not_found(error): |
|
|
return render_template('error.html'), 404 |
|
|
|
|
|
|
|
|
@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') |
|
|
|
|
|
|
|
|
@app.route('/android') |
|
|
def android(): |
|
|
return render_template('android.html') |
|
|
|
|
|
|
|
|
@app.route('/ios') |
|
|
def ios(): |
|
|
return render_template('ios.html') |
|
|
|
|
|
|
|
|
@app.route('/windows') |
|
|
def windows(): |
|
|
return render_template('windows.html') |
|
|
|
|
|
if __name__ == '__main__': |
|
|
app.run(debug=True) |
|
|
|