First Steps
Now that you’ve installed and configured Muebles Roble, let’s run the application and create your first catalog entries. This guide will walk you through starting the server and using the basic features.Make sure you’ve completed the Installation and Configuration guides before proceeding.
Starting the Application
Activate Virtual Environment
First, ensure your virtual environment is activated:You should see
(venv) in your terminal prompt.Run the Application
Start the Flask development server using one of these methods:You should see output like:
The “Database connection successful!” message confirms your database is configured correctly.
Understanding the Application URLs
The application is organized into modules with specific URL prefixes:| Module | Base URL | Purpose |
|---|---|---|
| Colors | http://localhost:5000/colors/ | Manage color catalog |
| Wood Types | http://localhost:5000/wood-types/ | Manage wood types |
| Furniture Types | http://localhost:5000/furniture-type/ | Manage furniture categories |
| Unit of Measures | http://localhost:5000/unit-of-measures/ | Manage measurement units |
| Roles | http://localhost:5000/roles/ | Manage user roles |
/- List all entries/create- Create a new entry/<id>/edit- Edit an existing entry/<id>/delete- Delete an entry (soft delete)
Creating Your First Color
Let’s start by creating color entries for your furniture finishes.Create Natural Color
Enter “Natural” in the color name field and click “Create Color” (or submit button).If successful, you’ll see a success message:The form will be cleared, ready for the next entry.
Create More Colors
Add these common furniture colors:
- White
- Black
- Walnut
- Mahogany
- Cherry
- Oak
- Espresso
Behind the Scenes: Color Creation
When you create a color, here’s what happens:1. Form Submission
1. Form Submission
The HTML form sends a POST request to
/colors/create:2. Route Handling
2. Route Handling
The route validates the form and calls the service:
3. Service Logic
3. Service Logic
The service validates business rules and saves to database:
4. Database Record
4. Database Record
A new record is created with automatic audit fields:
Creating Wood Types
Next, let’s add the types of wood your furniture shop uses.Add Common Wood Types
Create these standard wood types:
- Pine (Pino)
- Cedar (Cedro)
- Oak (Encino)
- Mahogany (Caoba)
- Maple (Arce)
- Cherry (Cerezo)
- Walnut (Nogal)
- Ash (Fresno)
Creating Furniture Types
Define the categories of furniture your shop produces.Add Furniture Categories
Create these common furniture types:
- Tables (Mesas)
- Chairs (Sillas)
- Closets (Closets)
- Desks (Escritorios)
- Shelves (Estantes)
- Cabinets (Gabinetes)
- Bookcases (Libreros)
- Nightstands (Burós)
- Dressers (Cómodas)
Creating Units of Measure
Add the measurement units used for tracking materials and products.Editing Catalog Entries
You can edit any catalog entry:Edit Flow
Here’s what happens during an edit:The system uses the PRG (Post-Redirect-Get) pattern to prevent duplicate submissions if the user refreshes the page.
Deleting Catalog Entries
The system uses soft deletion to preserve data:Soft Delete Implementation
Understanding Flash Messages
The application uses Flask’s flash messaging system for user feedback:Success Messages
Error Messages
Validating Data Entry
Try these scenarios to see validation in action:Duplicate Detection
Required Fields
Length Validation
Viewing the Database
You can verify your data was saved to MySQL:Testing CSRF Protection
Try submitting a form without the CSRF token:- Open browser developer tools (F12)
- Go to
/colors/create - In the console, try:
- The request will be rejected with a CSRF error
Development Tips
Auto-Reload
Flask’s debug mode automatically reloads when you change code:- Edit a file (e.g.,
routes.py) - Save the file
- The server automatically restarts
- Refresh your browser to see changes
Debug Mode Features
WithFLASK_ENV=development, you get:
- Detailed error pages - Stack traces in the browser
- Auto-reload - Automatic server restart on code changes
- Debug toolbar - (if installed) Request/response inspection
Viewing Logs
The terminal where you ranflask run shows:
- Timestamp
- HTTP method and path
- Response status code (200 = success, 302 = redirect)
Common Issues
Port already in use
Port already in use
Error:
Address already in useSolution: Either:- Stop the existing server (find and kill the process)
- Use a different port:
flask run --port 5001
Database connection failed
Database connection failed
Error:
Database connection failed: Access deniedSolution:- Verify your
.envfile has correct credentials - Check MySQL is running:
mysql -u root -p - Review the Configuration Guide
Page not found (404)
Page not found (404)
Error: 404 Not FoundSolution:
- Verify the URL is correct (check for typos)
- Ensure you’re using the right prefix (
/colors/, not/color/) - Check that the blueprint is registered in
app/__init__.py
Form doesn't submit
Form doesn't submit
Problem: Clicking submit does nothingSolution:
- Check browser console for JavaScript errors
- Verify the form has
method="POST" - Ensure
{{ form.hidden_tag() }}is present (CSRF token)
Next Steps
Now that you understand the basics:Key Features
Explore advanced features like audit trails and soft deletes
Architecture
Understand the layered MVC architecture in depth
Deploy to Production
Deploy the application to a production server