Web app with authentication (Google sign in and magic link) and a Landing Page

Test this app for free
19
import logging
from flask import Flask, url_for, request, session
from gunicorn.app.base import BaseApplication
from routes import routes as routes_blueprint
from authentication import auth, auth_required
from models import db, User
from abilities import apply_sqlite_migrations

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def create_app():
    app = Flask(__name__, static_folder='static')
    app.secret_key = 'supersecretkey'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.sqlite'
    db.init_app(app)

    with app.app_context():
        apply_sqlite_migrations(db.engine, db.Model, 'migrations')

    app.register_blueprint(routes_blueprint)
    app.register_blueprint(auth)
Get full code

Frequently Asked Questions

What types of businesses or applications would benefit most from this Flask web app template?

This Flask web app template with authentication is ideal for SaaS (Software as a Service) businesses and multi-tenant applications. It's particularly suitable for startups or companies looking to build: - Customer relationship management (CRM) systems - Project management tools - Online learning platforms - Personal finance management apps - Health and fitness tracking applications

The template's focus on individual user management without team features makes it perfect for services where users primarily interact with their own data.

How does this template support scalability for growing SaaS businesses?

The Flask web app template supports scalability in several ways: - It uses SQLAlchemy ORM, allowing easy database migrations as your data model evolves. - The authentication system (Google sign-in and magic link) is designed to handle a growing user base. - The use of Gunicorn as the WSGI HTTP Server allows for multiple worker processes, improving request handling capacity. - The template's structure separates concerns (routes, models, authentication), making it easier to maintain and expand functionality as the business grows.

Can you provide an example of how to add a new feature to the home page of this Flask web app template?

Certainly! Let's say we want to add a simple dashboard feature to the home page. We would modify the home_logged_in.html file and the corresponding route. Here's an example:

In routes.py, update the home_logged_in_route:

```python from flask import render_template, session from database_operations import get_user_by_email

@routes.route("/home_logged_in") @with_sidebar def home_logged_in_route(): user_email = session.get('user', {}).get('user_email') user_data = get_user_by_email(user_email) if user_email else None return render_template("home_logged_in.html", user_data=user_data) ```

Then in home_logged_in.html:

```html {% extends "layout.html" %} {% block content %}

Welcome, {{ user_data.email }}

Profile Information

Email: {{ user_data.email }}

User ID: {{ user_data.id }}

{% endblock %} ```

This example adds a simple dashboard displaying user information on the home page.

How does the authentication system in this Flask web app template enhance security for SaaS applications?

The authentication system in this Flask web app template enhances security for SaaS applications in several ways: - It uses Google sign-in, leveraging Google's robust security measures. - It includes a magic link option, which is a passwordless authentication method that reduces the risk of password-related vulnerabilities. - The template implements session management with customizable expiry times. - It uses HTTPS by default, ensuring encrypted communication between the client and server. - The authentication logic is centralized and can be easily updated or extended to include additional security measures as needed.

How can I customize the database schema in this Flask web app template to fit my specific SaaS needs?

To customize the database schema in this Flask web app template, you would primarily work with the models.py file and create new migration scripts. Here's an example of how you might extend the User model to include additional fields for a SaaS application:

In models.py:

```python from flask_sqlalchemy import SQLAlchemy from datetime import datetime

db = SQLAlchemy()

class User(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(150), unique=True, nullable=False) profile_picture = db.Column(db.String(255)) subscription_tier = db.Column(db.String(50), default='free') last_login = db.Column(db.DateTime, default=datetime.utcnow) created_at = db.Column(db.DateTime, default=datetime.utcnow)

class Project(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) description = db.Column(db.Text) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow)

   user = db.relationship('User', backref=db.backref('projects', lazy=True))

```

After modifying the models, you would create a new migration script:

flask db migrate -m "Add subscription and project models" flask db upgrade

This example adds a subscription tier to the User model and creates a new Project model associated with users, which could be useful for many SaaS applications built with this Flask web app template.

Created: | Last Updated:

This is a good starting point for any app that requires login and registration and an external page explaining the service. For example for a SaaS web app.

Here's a step-by-step guide for using the Landing Page with Login Functionality template:

Introduction

This template provides a landing page with user login functionality and a profile overview. It includes features like user authentication, a sidebar for navigation, and a home dashboard.

Getting Started

  1. Click "Start with this Template" to begin using this template in the Lazy Builder interface.

Test the Application

  1. Press the "Test" button in the Lazy Builder interface to deploy and run the application.

  2. Once deployed, Lazy will provide you with a server link to access your application.

Using the Application

  1. Open the provided server link in your web browser to view the landing page.

  2. The landing page will display a welcome message and a "Get Started" button.

  3. Click the "Get Started" button to proceed to the login page.

  4. On the login page, you can sign in using your Google account. The application uses Google authentication for user login.

  5. After successful authentication, you'll be redirected to the home dashboard.

Exploring the Home Dashboard

  1. The home dashboard includes:
  2. A sidebar with your profile picture and name
  3. A main content area with a welcome message and quick access cards
  4. A logout button in the top-right corner

  5. The sidebar allows you to navigate between different sections of the application (currently only "Home" is available).

  6. The main content area displays two quick access cards:

    • Profile Settings: A placeholder for future profile management features
    • Getting Started: A placeholder for a user guide
  7. To log out, click the "Logout" button in the top-right corner or use the logout option in the sidebar.

Customizing the Application

This template provides a solid foundation for a web application with user authentication. To further customize it:

  • Modify the home.html file to add more content or features to the dashboard.
  • Update the _sidebar.html file to add more navigation options.
  • Customize the CSS files (landing.css, sidebar.css, and profile.css) to change the application's appearance.

Remember that all customizations should be done within the Lazy Builder interface. The application is automatically deployed and managed by the Lazy platform, so you don't need to worry about server setup or environment configuration.



Template Benefits

  1. Rapid SaaS Development: This template provides a solid foundation for quickly building Software-as-a-Service (SaaS) applications, reducing development time and allowing businesses to launch their products faster.

  2. Secure Authentication: With built-in Google sign-in and magic link authentication, the template ensures robust security measures are in place, protecting user data and reducing the risk of unauthorized access.

  3. Multi-tenant Architecture: The template is designed for multi-tenant applications, allowing businesses to serve multiple customers from a single instance, improving scalability and reducing operational costs.

  4. User-Centric Design: The included sidebar and responsive layout offer a user-friendly interface, enhancing user experience and potentially increasing user engagement and retention.

  5. Customizable and Extensible: The modular structure of the template makes it easy to customize and extend functionality, enabling businesses to tailor the application to their specific needs and add new features as they grow.

Technologies

Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More
Flask Templates from Lazy AI – Boost Web App Development with Bootstrap, HTML, and Free Python Flask Flask Templates from Lazy AI – Boost Web App Development with Bootstrap, HTML, and Free Python Flask
Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More
Streamline JavaScript Workflows with Lazy AI: Automate Development, Debugging, API Integration and More  Streamline JavaScript Workflows with Lazy AI: Automate Development, Debugging, API Integration and More
Python App Templates for Scraping, Machine Learning, Data Science and More Python App Templates for Scraping, Machine Learning, Data Science and More

Similar templates

We found some blogs you might like...