Browse Source

将文件生成的临时目录

pull/3/head
malaohu 4 years ago committed by GitHub
parent
commit
2083932225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app.py

14
app.py

@ -96,12 +96,12 @@ def GenerateLicense(Type : LicenseType, Count : int, UserName : str, MajorVersio
0, # No Games flag. 0 means "NoGames = false". But it does not work. 0, # No Games flag. 0 means "NoGames = false". But it does not work.
0) # No Plugins flag. 0 means "NoPlugins = false". But it does not work. 0) # No Plugins flag. 0 means "NoPlugins = false". But it does not work.
EncodedLicenseString = VariantBase64Encode(EncryptBytes(0x787, LicenseString.encode())).decode() EncodedLicenseString = VariantBase64Encode(EncryptBytes(0x787, LicenseString.encode())).decode()
with zipfile.ZipFile(EncodedLicenseString, 'w') as f: with zipfile.ZipFile('/tmp/' + EncodedLicenseString, 'w') as f:
f.writestr('Pro.key', data = EncodedLicenseString) f.writestr('Pro.key', data = EncodedLicenseString)
return EncodedLicenseString return EncodedLicenseString
@app.route('/') @app.route('/gen')
def get_lc(): def get_lc():
name = request.args.get('name', '') name = request.args.get('name', '')
version = request.args.get('ver', '') version = request.args.get('ver', '')
@ -111,14 +111,22 @@ def get_lc():
lc = GenerateLicense(LicenseType.Professional, 1, name, MajorVersion, MinorVersion) lc = GenerateLicense(LicenseType.Professional, 1, name, MajorVersion, MinorVersion)
return lc return lc
@app.route('/download/<lc>') @app.route('/download/<lc>')
def download_lc(lc): def download_lc(lc):
if lc and len(lc) > 5 and os.path.exists('./' + lc): if lc and len(lc) > 5 and os.path.exists('./' + lc):
return send_file('./' + lc, return send_file('/tmp/' + lc,
as_attachment=True, as_attachment=True,
attachment_filename='Custom.mxtpro') attachment_filename='Custom.mxtpro')
else: else:
return "请确保生成成功后再来下载!" return "请确保生成成功后再来下载!"
@app.route('/')
def get():
lc = get_lc()
return download_lc(lc)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=False) app.run(host='0.0.0.0', port=5000, debug=False)

Loading…
Cancel
Save