Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, request, redirect, url_for
- from flask_sqlalchemy import SQLAlchemy
- from model import User
- from werkzeug.security import generate_password_hash, check_password_hash
- import os
- app = Flask(__name__)
- app.config['SECRET_KEY'] = 'PRODUCTION SECRET KEY'
- app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.abspath(os.getcwd())+ '/database.db'
- app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
- app.debug = True
- db = SQLAlchemy(app)
- @app.route('/')
- def index():
- user = User(
- username="helloworld",
- email="helloworld@gmail.com",
- password=generate_password_hash("helloworld", method="sha256")
- )
- db.session.add(user)
- db.session.commit()
- return "<h1> Added new User </h1>"
- if __name__ == '__main__':
- app.run()
Add Comment
Please, Sign In to add comment