前幾天玉山推出了 新的信用卡 ubear , 雖然有8 % 的超商回饋, 但有200元的限制
超過 我要改刷 Pi
於是快速寫了一個 python flask 小程式放在自己的網路上紀錄刷了多少
source code 如下, html 我就不貼了 很短
from flask import Flask
from flask import render_template,request,redirect, url_for,flash
from datetime import datetime
import time
totalNum = 0
numList = []
app = Flask(__name__)
@app.route('/input', methods=['GET'])
def getdata():
global totalNum
global numList
return render_template('input.html',totalNum=totalNum, numList=numList)
#
@app.route('/input', methods=['POST'])
def submit():
global totalNum
global numList
if request.form.get('clear'):
totalNum=0
numList =[]
else:
number = request.form.get('numbers')
print(type(number))
import time
localtime = time.asctime( time.localtime(time.time()) )
moneyRec = "NT " + number +" " + localtime
numList.append(moneyRec)
totalNum = int(number) + totalNum
return render_template('input.html',totalNum=totalNum, numList=numList)
if __name__ == '__main__':
app.run(host= '0.0.0.0' , port=1000, debug=False)