kimbank / LOTTO

로또 번호 생성기 (Discontinued)

Home Page:https://kimbank.github.io/LOTTO/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🔨Stack🔨







1. lotto API


1-1. lotto.csv

역대 로또 당첨 번호

https://dhlottery.co.kr/gameResult.do?method=byWin


1-2. lambda_function.py

1) 1 ~ 45 랜덤 번호 6개 생성

2) lotto.csv 에 1)의 조합이 있을 경우 번호 재 조합

3) lotto.csv 에 1)의 조합이 없을 경우 1의 번호 조합

import random
import json


def makingLottoDBList():
  lottoDBList = []
  lottoDBListIndexCount = 0

  lottoDBLines = open("lotto.csv", 'r')
  lottoDBLinesTemp = lottoDBLines.readlines()
  for lottoDBLineTemp in lottoDBLinesTemp:
      lottoDBLineTemp = lottoDBLineTemp.strip()
      lottoDBList.append(list(map(int, lottoDBLineTemp.split("\t"))))
      lottoDBList[lottoDBListIndexCount].pop()
      lottoDBListIndexCount += 1
  lottoDBLines.close()
  return lottoDBList


def makingLottoNumber():
  lottoNumber = []
  while True:
    lottoNumberRandom = random.randrange(1, 46)
    if len(lottoNumber) == 6: 
      break
    elif lottoNumberRandom not in lottoNumber: 
      lottoNumber.append(lottoNumberRandom)
  lottoNumber.sort()

  return lottoNumber


def lambda_handler(event, context):
  makingLottoNumberTemp = makingLottoNumber()
  lottoDBList = makingLottoDBList()
  while True:
      if makingLottoNumberTemp not in lottoDBList:
        break
      makingLottoNumberTemp = makingLottoNumber()
      
  n1 = "%d" %makingLottoNumberTemp[0]
  n2 = "%d" %makingLottoNumberTemp[1]
  n3 = "%d" %makingLottoNumberTemp[2]
  n4 = "%d" %makingLottoNumberTemp[3]
  n5 = "%d" %makingLottoNumberTemp[4]
  n6 = "%d" %makingLottoNumberTemp[5]
  
  data = {
    'n1': n1,
    'n2': n2,
    'n3': n3,
    'n4': n4,
    'n5': n5,
    'n6': n6
  }
  
  return {
    'statusCode': 200,
    'headers': {'Access-Control-Allow-Origin': '*'},
    'body': json.dumps(data)
  }



2. AWS Lambda

Test Lambda REST API test link

https://skp7t6j64m.execute-api.ap-northeast-2.amazonaws.com/2021-11-24/lotto



3. HTML UI

https://pit-and-pat.tistory.com/6

위 블로그의 html 디자인 포멧을 사용하였습니다.



About

로또 번호 생성기 (Discontinued)

https://kimbank.github.io/LOTTO/


Languages

Language:HTML 38.3%Language:Python 34.7%Language:JavaScript 15.0%Language:CSS 12.0%