Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. from flask import Flask
  2. from flask_sqlalchemy import SQLAlchemy
  3.  
  4. app = Flask(__name__)
  5. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///C:\\Users\\Admin\\Raffle5\\app.db'
  6. db = SQLAlchemy(app)
  7.  
  8. @app.route('/')
  9. def hello_world():
  10. return 'Hello, World!'
  11.  
  12. class User(db.Model):
  13. id = db.Column(db.Integer, primary_key=True)
  14. email = db.Column(db.String(120), unique=True)
  15. raffle_colour = db.Column(db.String(120), unique=True)
  16. raffle_ticket = db.Column(db.Integer, unique=True)
  17.  
  18. def __init__(self, username, email):
  19. self.username = username
  20. self.email = email
  21.  
  22. def __repr__(self):
  23. return '<User %r>' % self.username
  24.  
  25.  
  26. def insert_raffle(raffle,raffle_table):
  27. for i in range(raffle):
  28. ins_raffle = raffles_table.insert()
  29. COLORS = "Blue Pink Plum Aqua Navy Grey Rose Ruby Teal Gold Jade Lime".split()
  30. BASE = 10 * 8
  31. NUM_COLORS = len(COLORS)
  32. ticket = random.randrange(NUM_COLORS * BASE)
  33. new_raffle = ins_raffle.values(email = email, raffle_colour = color, raffle_ticket = ticket)
  34. conn.execute(new_raffle)
  35. color_index, rem = divmod(ticket, BASE)
  36. color = COLORS[color_index]
  37. num_a, num_b = divmod(rem, 10 ** 4)
  38. print("Your ticket is: {} {:04d} {:04d}". format(color, num_a, num_b))
  39.  
  40. #this is code to actually start the flask server
  41. #once we get this running without error, we can add the raffle code otherwise we'll not know if it works or not
  42. #can you copy that error in codementor chat
  43. #this command installs all the requirements for the project
  44. #pip install -r requirements.txt
  45. #error fixed..
  46. #can you open a terminal please
  47. #ok so you fixed that, cool.
  48. #which code is giving you the issue ? im trying to add form where email and number of raffles and im not sure
  49. #ok where is the code for raffle and form located i have only got the raffle code
  50. #what do you expect this project to do in terms of input and output ? normal
  51. if __name__ == '__main__':
  52. #app.config['DEBUG'] = True
  53. #app.run(debug=True, host='0.0.0.0', port=5000, threaded=True)
  54. app.run()
  55. #could you please
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement