Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask
- from flask_sqlalchemy import SQLAlchemy
- app = Flask(__name__)
- app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///C:\\Users\\Admin\\Raffle5\\app.db'
- db = SQLAlchemy(app)
- @app.route('/')
- def hello_world():
- return 'Hello, World!'
- class User(db.Model):
- id = db.Column(db.Integer, primary_key=True)
- email = db.Column(db.String(120), unique=True)
- raffle_colour = db.Column(db.String(120), unique=True)
- raffle_ticket = db.Column(db.Integer, unique=True)
- def __init__(self, username, email):
- self.username = username
- self.email = email
- def __repr__(self):
- return '<User %r>' % self.username
- def insert_raffle(raffle,raffle_table):
- for i in range(raffle):
- ins_raffle = raffles_table.insert()
- COLORS = "Blue Pink Plum Aqua Navy Grey Rose Ruby Teal Gold Jade Lime".split()
- BASE = 10 * 8
- NUM_COLORS = len(COLORS)
- ticket = random.randrange(NUM_COLORS * BASE)
- new_raffle = ins_raffle.values(email = email, raffle_colour = color, raffle_ticket = ticket)
- conn.execute(new_raffle)
- color_index, rem = divmod(ticket, BASE)
- color = COLORS[color_index]
- num_a, num_b = divmod(rem, 10 ** 4)
- print("Your ticket is: {} {:04d} {:04d}". format(color, num_a, num_b))
- #this is code to actually start the flask server
- #once we get this running without error, we can add the raffle code otherwise we'll not know if it works or not
- #can you copy that error in codementor chat
- #this command installs all the requirements for the project
- #pip install -r requirements.txt
- #error fixed..
- #can you open a terminal please
- #ok so you fixed that, cool.
- #which code is giving you the issue ? im trying to add form where email and number of raffles and im not sure
- #ok where is the code for raffle and form located i have only got the raffle code
- #what do you expect this project to do in terms of input and output ? normal
- if __name__ == '__main__':
- #app.config['DEBUG'] = True
- #app.run(debug=True, host='0.0.0.0', port=5000, threaded=True)
- app.run()
- #could you please
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement