A Flask-based web application that lets users browse cafes with Wi-Fi, view details, and even request new cafes or changes. Administrators can add, edit, and delete cafes, while regular users can register, log in, and request updates via email notifications.
- Browse Cafes: View a list of cafes along with details such as location, available amenities (sockets, toilets, Wi-Fi), seating capacity, and coffee price.
- View Details: Click on a cafe to see additional details and images.
- Admin Controls:
- Add Cafe: Only the admin (user with
id=1
) can add new cafes. - Edit Cafe: Modify the details of an existing cafe.
- Delete Cafe: Remove a cafe from the listing.
- Add Cafe: Only the admin (user with
- Request Cafe: Users can submit requests for a new cafe or changes to an existing one. These requests are sent via email.
- User Authentication:
- Register: New users can sign up.
- Login/Logout: Secure login with hashed passwords using Flask-Login and Werkzeug.
- Python 3
- Flask – Web framework for Python.
- Flask-Login – User session management.
- Flask-SQLAlchemy – ORM for database operations.
- Flask-WTF – Form handling and validation.
- SQLAlchemy – Database toolkit.
- Werkzeug – Provides secure password hashing.
- python-dotenv – For loading environment variables.
- Secrets – For generating secure tokens.
-
Clone the repository:
git clone https://github.com/mhrafin/Cafe-Wifi-Website.git cd Cafe-Wifi-Website
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Set up the database:
The project uses SQLite. When you run the application, it will automatically create the
project.db
file and the necessary tables.
-
Environment Variables:
Create a
.env
file in the project root and add your email credentials. For example:EMAIL=[email protected] PASSWORD=your-email-password
These credentials are used by the
EmailSender
to send cafe request emails via Gmail's SMTP server. -
Secret Key:
The app generates a random secret key on startup using the
secrets
module. For production use, you may want to set a fixed secret key in your environment variables.
-
Run the Application:
python main.py
-
Open in Browser:
Visit http://127.0.0.1:5000 in your web browser to start using the website.
-
User Roles:
- Admin: The first registered user (with
id=1
) has administrative privileges. This user can add, edit, and delete cafes. - Regular User: Can browse cafes, view details, and submit cafe requests.
- Admin: The first registered user (with
-
Forms and Validation:
The app uses Flask-WTF to handle form data. Forms include validations for required fields, URLs, email formats, and more.