Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cdserver.py
- import os, sys, json, subprocess
- from flask import Flask, render_template, flash
- from flask_cors import cross_origin, CORS
- app = Flask(__name__)
- app.config['SECRET_KEY'] ="abcdef"
- cors = CORS(app, resources={r"/checkkey/*/*": {"origins": "*"}})
- #checkKey takes in a cdkey, and a uuid number. If the cd key is present in our list of valid cdkeys, it checks whether the UUID being passed is the one registered, if so , return a value of 100(Valid)
- #if not the UUID registered, return type 200(Invalid UUID). If the cdkey isn't a valid key, return type 300 - Invalid Key.
- # First time customer :
- # Admin mode > passwd set> enter cdkey > check if key valid and uuid unset> set cdkey value as uuid> return good status
- #Customer needs to replace computer, trys to install software, it already has a UUID associated with it, so a message appears stating so, and a contact numer. We would just unset the UUID, and let
- # them reinstall.
- #This is the cdkey checker upon admin>cdkey enter
- @app.route("/checkkey/<cdkey>/<uuidNum>", methods=['POST', "GET"])
- @cross_origin()
- def checkKey(cdkey, uuidNum):
- #REMEMBER TO CHANGE BEFORE UPLOADING TO SERVER
- cd_key_file = os.getcwd() + "\\static\\keys.json"
- with open(cd_key_file, 'r+') as keyfile:
- keydata = json.load(keyfile)
- #Check each cd key available, and test against given information (cdkey/ uuid)
- if cdkey in keydata['certificates']['keys'].keys():
- if keydata['certificates']['keys'][cdkey] == "unset":
- with open(cd_key_file, 'w') as writekeyfile:
- keydata['certificates']['keys'][cdkey] = uuidNum
- json.dump(keydata, writekeyfile)
- print('100 - Valid - Key Registered')
- return str('100 - Valid - Key Registered')
- elif keydata['certificates']['keys'][cdkey] == uuidNum:
- print('100 - Valid')
- return str('100 - Valid')
- else:
- print('200 - Cd key already in use')
- return str('200 - Cd key already in use on another computer. Please purchase another license key.')
- else:
- print('300 - Invalid Key')
- return str('300 - Invalid Key')
- if __name__ == "__main__":
- app.run(host="127.0.0.1", port="80")
- ------------------------------
- cdserver.yaml
- runtime: python37
- handlers:
- - url: /*
- http_headers:
- Access-Control-Allow-Origin: *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement