Guest User

Untitled

a guest
Jul 4th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. from flask import Flask, render_template, request, redirect, url_for
  2. from flask_sqlalchemy import SQLAlchemy
  3. from model import User
  4. from werkzeug.security import generate_password_hash, check_password_hash
  5. import os
  6.  
  7.  
  8. app = Flask(__name__)
  9. app.config['SECRET_KEY'] = 'PRODUCTION SECRET KEY'
  10. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.abspath(os.getcwd())+ '/database.db'
  11. app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  12. app.debug = True
  13. db = SQLAlchemy(app)
  14.  
  15. @app.route('/')
  16. def index():
  17. user = User(
  18. username="helloworld",
  19. email="helloworld@gmail.com",
  20. password=generate_password_hash("helloworld", method="sha256")
  21. )
  22.  
  23. db.session.add(user)
  24. db.session.commit()
  25.  
  26. return "<h1> Added new User </h1>"
  27.  
  28. if __name__ == '__main__':
  29. app.run()
Add Comment
Please, Sign In to add comment