auto_rest.app¶
The app
module provides factory functions and utilities for building and
deploying Fast-API applications.
Example: Build and Deploy an API
from auto_rest.app import create_app, run_server
app = create_app(app_title="My Application", app_version="1.2.3")
... # Add endpoints to the application here
run_server(app, host="127.0.0.1", port=8081)
create_app(app_title, app_version)
¶
Create and configure a FastAPI application instance.
This function initializes a FastAPI app with a customizable title, version, and optional documentation routes. It also configures application middleware for CORS policies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_title
|
str
|
The title of the FastAPI application. |
required |
app_version
|
str
|
The version of the FastAPI application. |
required |
Returns:
Name | Type | Description |
---|---|---|
FastAPI |
FastAPI
|
A configured FastAPI application instance. |
Source code in auto_rest/app.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
logging_middleware(request, call_next)
async
¶
FastAPI middleware for the logging response status codes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
The incoming HTTP request. |
required |
call_next
|
callable
|
The next middleware in the middleware chain. |
required |
Returns:
Type | Description |
---|---|
Response
|
The outgoing HTTP response. |
Source code in auto_rest/app.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
run_server(app, host, port)
¶
Deploy a FastAPI application server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app
|
FastAPI
|
The FastAPI application to run. |
required |
host
|
str
|
The hostname or IP address for the server to bind to. |
required |
port
|
int
|
The port number for the server to listen on. |
required |
Source code in auto_rest/app.py
80 81 82 83 84 85 86 87 88 89 90 |
|