Last active
February 2, 2021 02:03
-
-
Save SirmaXX/8645ba5a16bb306bf2647ff64842fbaa to your computer and use it in GitHub Desktop.
coupon service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask,request, url_for,render_template | |
import random | |
import string | |
app =Flask(__name__) | |
coupons=[] | |
def CouponCreator(number,length ): | |
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@£$%^&*().,?0123456789' | |
for cpn in range(number): | |
coupon = '' | |
print(coupons) | |
for c in range(length): | |
coupon += random.choice(chars) | |
coupons.append(coupon) | |
@app.route('/api/<number>/<length>', methods = ["GET","POST"]) | |
def coupon_api(number,length): | |
number =int(number) | |
length =int(length) | |
return passcreator(number,length ) | |
@app.route('/') | |
def index(): | |
return CouponCreator(2,2 ) | |
if __name__ == "__main__": | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment