How to Set Up Your FlaskDash Starter App

Nov 18, 2023 | Programming

Welcome to the exciting world of Flask web applications! If you’re ready to embark on your next development adventure using the FlaskDash starter app v1.7, you’ve come to the right place. This guide will walk you through the setup process, functionality, and troubleshooting, ensuring a smooth sailing experience as you build your web application.

Understanding FlaskDash Starter App

The FlaskDash starter app is like a well-organized toolbox ready for your DIY project. It provides you with a solid foundation based on the amazing work of Ling Thio, complete with the CoreUI admin Bootstrap theme, user management features, and a dedicated view file for API code.

Key Features at a Glance

  • Compatible with Python 2.6 through 3.8
  • Well-structured directory with extensive documentation
  • Includes testing frameworks (py.test and tox)
  • Database migration support with Alembic
  • Email notifications for unhandled exceptions

Setting Up Your Development Environment

Before diving into the code, ensure you have Git, Virtualenv, and Virtualenvwrapper installed. Let’s get started!

# Clone the repository into ~/dev/my_app
mkdir -p ~/dev
cd ~/dev
git clone https://github.com/twintechlabs/flaskdash.git my_app

# Create the my_app virtual environment
mkvirtualenv -p PATHTOPYTHON my_app

# Install required Python packages
cd ~/dev/my_app
workon my_app
pip install -r requirements.txt

Configuring SMTP

Edit your local_settings.py file to configure your email settings. For Google SMTP, ensure you’ve enabled access for less secure apps by visiting this link. If you’re using Yahoo SMTP, refer to this guide.

Initializing the Database

To set up your database tables properly, run the following command:

# Create DB tables and populate roles and users
python manage.py init_db

# Or if you have Fabric installed:
fab init_db

Running the App

In Development Mode

Launch the app by entering:

# Start the Flask development web server
python manage.py runserver

# Or with Fabric:
fab runserver

Access the application locally at http://localhost:5000. You can log in using:

  • Member: member@example.com with password Password1
  • Admin: admin@example.com with password Password1

In Production Mode

For production, utilize Gunicorn:

# Run the application in production mode
./runserver.sh

Running Automated Tests

To ensure your code is working smoothly, execute:

# Start automated tests
py.test tests

# Or with Fabric:
fab test

Working with Server-side Sessions

Avoid using server-side session data unless absolutely necessary. Keeping requests stateless simplifies debugging and maintenance. However, if sessions are needed, FlaskDash includes Flask-Session, configurable to use SQLAlchemy, Redis, or MongoDB.

# Example of using sessions
session[key] = value
val = session.get(key, not set)
print(val)
value = session.get(key2, not set)
print(val)

Troubleshooting Tips

If you encounter database schema issues after modifying models, consider deleting the SQLite DB file app.sqlite. This will clear any conflicts and allow a fresh start.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Happy coding with your FlaskDash application!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox