프로젝트

일반

사용자정보

개정판 5aa151cb

ID5aa151cbd3e97e4e03470bc3a491fd81ee50ca9f
상위 78a9d434
하위 ec3c920c, e405c3e0

백흠경이(가) 4년 이상 전에 추가함

issue #1366: modified generate license key routine

Change-Id: I3f88eeb6c6d8b836a5286a03da051f7ad9cdd777

차이점 보기:

DTI_PID/WebServer/app/license/index.py
2 2
# pwd : /project_name/app/license/index.py
3 3

  
4 4
from flask import Blueprint, request, render_template, flash, redirect, url_for
5
from flask_wtf import FlaskForm
6
from wtforms import *
7
from wtforms.validators import *
5 8
from flask import current_app as app
6 9

  
7 10
license_service = Blueprint('license', __name__, url_prefix='/license')
8 11

  
9 12

  
10
@license_service.route('/', methods=['GET'])
11
def index():
12
    return render_template("/license/index.html")
13

  
14

  
15
@license_service.route('/gen_key', methods=['POST'])
16
def gen_key():
17
    import base64
13
class LicenseForm(FlaskForm):
14
    csrf_token = 'id2 web service'
15
    authorization = PasswordField('Authorization :')
16
    computer_name = StringField('Computer Name :')
17
    submit = SubmitField('Submit')
18 18

  
19
    if request.method == 'POST':
20
        r = request
19
    @staticmethod
20
    def generate_license_key(pw: str, clear: str) -> str:
21
        import base64
21 22

  
22 23
        key = 'Image Drawing to Intelligent Drawing'
23 24

  
24
        pw = r.form['Authorization']
25
        clear = r.form['Computer_Name']
26

  
27 25
        if pw != 'admin':
28 26
            return 'Invalid Authorization'
29 27

  
......
35 33

  
36 34
        new_key = base64.urlsafe_b64encode(bytes(enc))
37 35

  
38
        return 'License Key for ' + clear + ' : ' + new_key.decode('utf-8')
36
        return new_key.decode('utf-8')
37

  
38

  
39
@license_service.route('/', methods=['GET', 'POST'])
40
def index():
41
    authorization = None
42
    computer_name = None
43
    code = None
44

  
45
    form = LicenseForm()
46
    if form.validate_on_submit():
47
        authorization = form.authorization.data
48
        computer_name = form.computer_name.data
49
        code = LicenseForm.generate_license_key(authorization, computer_name)
50
        form.authorization.data = ''
51
        form.computer_name.data = ''
52

  
53
    return render_template("/license/index.html", form=form, authorization=authorization, computer_name=computer_name,
54
                           code=code)
55

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)