Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5009CEM_Git_Test1/register.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (31 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from markupsafe import escape | |
from flask import url_for | |
from flask import render_template | |
from flask import request | |
from flask import redirect | |
from flask import abort | |
from flask import make_response | |
import sqlite3 | |
app = Flask(__name__) | |
@app.route('/register', methods=['GET', 'POST']) | |
def register(): | |
if request.method == 'POST': | |
return do_the_registration(request.form['uname'], request.form['pwd']) | |
else: | |
return show_the_registration_form(); | |
def show_the_registration_form(): | |
return render_template('register.html',page=url_for('register')) | |
def do_the_registration(u,p): | |
con = sqlite3.connect('registered_users.db') | |
try: | |
con.execute('CREATE TABLE users (name TEXT, pwd TEXT)') | |
#print ('Table created successfully'); | |
except: | |
pass | |
con.close() | |
con = sqlite3.connect('registered_users.db') | |
con.execute("INSERT INTO users values(?,?);", (u, p)) | |
con.commit() | |
con.close() | |
return show_the_login_form() |