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ο
Functionsο
|
Load a user from the database by ID. |
Handle 403 Forbidden errors. |
|
Handle 404 Not Found errors. |
|
Handle 405 Method Not Allowed errors. |
|
|
Handle 429 Too Many Requests errors. |
|
Handle 500 Internal Server errors. |
Check if the current user is authenticated. |
|
|
Serve the favicon.ico file. |
|
Serve the robots.txt file for web crawlers. |
|
Handle batch file validation uploads and job creation. |
|
Validate a single email address. |
|
Serve the index page or dynamically route for other pages with existing templates. |
Module Contentsο
- 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:
- 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.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