def create_user(): session = Session() new_user = User() new_user.fullname = flask.request.form["fullname"] new_user.name = flask.request.form["name"] new_user.password = flask.request.form["password"] session.add(new_user) session.commit() session.close() return flask.render_template("register.html",name = "completed")
def login_auth(): username = flask.request.form["username"] password = flask.request.form["password"] session = Session() users = session.query(User).filter(User.name == username).first() if users is None: log = "kullanıcı bulunamadı" else : if users.password == password: log ="Giriş Yaptınız" else : log = "Kullanıcı Adı ve ya Şifre Yanlış" session.close() return flask.render_template("login.html",log=log)
def users_json(): if flask.request.args.get('api_key')=='123': session = Session() all_users = session.query(User).all() session.close() liste = [] for i in all_users: liste.append({ 'id' : i.id, 'isim' : i.name, 'FullName': i.fullname, 'Password' : api_tools.md5_converter(i.password) }) return flask.jsonify(liste) else: return flask.abort(404)
from db_model import User,Session session = Session() #INSERT deneme = User() deneme.fullname = "deneme-full" deneme.name = "deneme-name" deneme.password = "******" session.add(deneme) session.commit() #WHERE users = session.query(User).filter(User.id==2).first() users.name = "degistirdim" #DELETE users = session.query(User).filter(User.id == 2).first() session.delete(users) session.commit() #SELECT print(session.query(User).all()) session.close()
def index(): session = Session() all_users = session.query(User).all() session.close() return flask.render_template("index.html" , users = all_users)