https://github.com/eniompw/simplelogin
Barebones Login and Signup in Flask using SQLite
https://github.com/eniompw/simplelogin
flask flask-application html login signup sqlite3
Last synced: 2 months ago
JSON representation
Barebones Login and Signup in Flask using SQLite
- Host: GitHub
- URL: https://github.com/eniompw/simplelogin
- Owner: eniompw
- License: mit
- Created: 2023-10-03T15:48:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-25T17:24:25.000Z (over 1 year ago)
- Last Synced: 2025-02-25T18:30:33.254Z (over 1 year ago)
- Topics: flask, flask-application, html, login, signup, sqlite3
- Language: Python
- Homepage: https://simple-login-tawny.vercel.app
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Flask Login Signup using SQLite
* [Based on Flask Login](https://github.com/eniompw/FlaskLogin)
## Overview
This is a simple web application built with Flask that demonstrates user authentication functionality (login and signup) using SQLite for data storage. The application allows users to create accounts and login with their credentials.
## Features
- User registration (signup)
- User authentication (login)
- SQLite database integration
- Simple web interface
## Code
### app.py
```python
from flask import Flask, render_template, request
import sqlite3
app = Flask(__name__)
@app.route('/')
def login():
return render_template('login.html')
@app.route('/signup')
def signup():
return render_template('signup.html')
@app.route('/select', methods=['post'])
def select():
con = sqlite3.connect('login.db')
cur = con.cursor()
cur.execute("SELECT * FROM users WHERE username=? AND password=?",
(request.form['un'],request.form['pw']))
match = len(cur.fetchall())
con.close()
if match == 0:
return "wrong username and password"
else:
return "welcome " + request.form['un']
@app.route('/insert', methods=['post'])
def insert():
con = sqlite3.connect("login.db")
cur = con.cursor()
cur.execute(""" INSERT INTO users (username, password)
VALUES (?, ?) """,
(request.form['un'], request.form['pw']))
con.commit()
con.close()
return 'signup successful'
```
## How to Run
1. Install the required dependencies from `requirements.txt`
2. Make sure the database is created using `create_table.py`
3. Run the Flask application using `python app.py`
4. Access the application in your web browser