app.views

Public views and routes for the Mail List Shield application.

This module defines the public-facing routes including the landing page, email validation endpoints, and error handlers. It also configures rate limiting for the application.

Attributes

public_bp

limiter

Functions

load_user(user_id)

Load a user from the database by ID.

forbidden_error(e)

Handle 403 Forbidden errors.

not_found_error(e)

Handle 404 Not Found errors.

method_not_allowed_error(e)

Handle 405 Method Not Allowed errors.

rate_limited(e)

Handle 429 Too Many Requests errors.

server_error(e)

Handle 500 Internal Server errors.

is_user_logged_in()

Check if the current user is authenticated.

favicon()

Serve the favicon.ico file.

robots()

Serve the robots.txt file for web crawlers.

validate_file(path)

Handle batch file validation uploads and job creation.

validate()

Validate a single email address.

index(path)

Serve the index page or dynamically route for other pages with existing templates.

Module Contents

app.views.public_bp[source]
app.views.load_user(user_id)[source]

Load a user from the database by ID.

This callback is used by Flask-Login to reload the user object from the user ID stored in the session.

Parameters:

user_id – The ID of the user to load.

Returns:

The user object, or None if not found.

Return type:

Users

app.views.forbidden_error(e)[source]

Handle 403 Forbidden errors.

Parameters:

e – The exception that triggered the error.

Returns:

Error page response and status code.

Return type:

tuple

app.views.not_found_error(e)[source]

Handle 404 Not Found errors.

Parameters:

e – The exception that triggered the error.

Returns:

Error page response and status code.

Return type:

tuple

app.views.method_not_allowed_error(e)[source]

Handle 405 Method Not Allowed errors.

Parameters:

e – The exception that triggered the error.

Returns:

Error page response and status code.

Return type:

tuple

app.views.rate_limited(e)[source]

Handle 429 Too Many Requests errors.

Parameters:

e – The exception that triggered the error.

Returns:

Error page response and status code.

Return type:

tuple

app.views.server_error(e)[source]

Handle 500 Internal Server errors.

Parameters:

e – The exception that triggered the error.

Returns:

Error page response and status code.

Return type:

tuple

app.views.limiter[source]
app.views.is_user_logged_in()[source]

Check if the current user is authenticated.

Returns:

True if the user is logged in, False otherwise.

Return type:

bool

app.views.favicon()[source]

Serve the favicon.ico file.

Returns:

The favicon file from static assets.

Return type:

Response

app.views.robots()[source]

Serve the robots.txt file for web crawlers.

Returns:

A text response with crawler directives.

Return type:

Response

app.views.validate_file(path)[source]

Handle batch file validation uploads and job creation.

Provides endpoints for getting signed upload URLs and recording batch job details after file upload.

Parameters:

path – The sub-path determining the action: - β€˜getSignedRequest’: Returns a signed URL for file upload. - β€˜recordBatchFileDetails’: Records job details after upload.

Returns:

JSON response with signed URL or job confirmation.

Return type:

Response

app.views.validate()[source]

Validate a single email address.

Processes email validation requests from the web interface. Anonymous users are limited to 5 validations per day. Authenticated users must have confirmed email and available credits.

Returns:

Validation result and HTTP status code.
  • 200: Successful validation with result data.

  • 402: Insufficient credits.

  • 403: Email not confirmed.

  • 500: Server error.

Return type:

tuple

app.views.index(path)[source]

Serve the index page or dynamically route for other pages with existing templates.

Parameters:

path (str) – The path to the requested page.

Returns:

The rendered HTML template for the requested page.

Return type:

Response