From 88aaef48327bb7be9ab5488dab20f10c5ece32c3 Mon Sep 17 00:00:00 2001 From: Q01 Date: Sun, 2 May 2021 12:36:47 +0800 Subject: [PATCH] Add: Default route for index. --- app.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index c01a1bb..4cbaa51 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,7 @@ #/usr/bin/env python3 import os, sys, zipfile -from flask import Flask -from flask import request -from flask import send_file +from flask import Flask, request, send_file, redirect, url_for import os.path app = Flask(__name__) @@ -102,34 +100,44 @@ def GenerateLicense(Type : LicenseType, Count : int, UserName : str, MajorVersio return FileName -@app.route('/gen') +#@app.route('/gen') def get_lc(): name = request.args.get('name', '') version = request.args.get('ver', '') count = int(request.args.get('count', '1')) - - MajorVersion, MinorVersion = version.split('.')[0:2] + try: + MajorVersion, MinorVersion = version.split('.')[0:2] + except: + return MajorVersion = int(MajorVersion) MinorVersion = int(MinorVersion) lc = GenerateLicense(LicenseType.Professional, count, name, MajorVersion, MinorVersion) return lc -@app.route('/download/') +#@app.route('/download/') def download_lc(lc): if lc and len(lc) > 5 and os.path.exists('./' + lc): return send_file(lc, as_attachment=True, attachment_filename='Custom.mxtpro') else: - return "请确保生成成功后再来下载!检查用户名版本号是否正确!" + return "请检查用户名版本号是否正确!" -@app.route('/') +@app.route('/gen') def get(): lc = get_lc() return download_lc(lc) +@app.route('/') +def index(): + return send_file('index.html') + + + + if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000, debug=True) + app.run(host='0.0.0.0', port=5000, debug=False) +