Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Last active February 2, 2021 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirmaXX/8645ba5a16bb306bf2647ff64842fbaa to your computer and use it in GitHub Desktop.
Save SirmaXX/8645ba5a16bb306bf2647ff64842fbaa to your computer and use it in GitHub Desktop.
coupon service
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