Monday, 17 August 2026

how to add swagger to docsify

 Method 1: Using docsify-swagger

The docsify-swagger GitHub repository provides a lightweight plugin to parse and render a Swagger JSON or YAML document natively within your custom Docsify pages. [1, 2]
1. Update index.html
Add the plugin script inside your main index.html file, right below the main Docsify script: [1, 2]
html
<!-- Main Docsify script -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>

<!-- Docsify-swagger plugin -->
<script src="//cdn.jsdelivr.net/npm/docsify-swagger/dist/docsify-swagger.min.js"></script>
Use code with caution.
2. Embed the Swagger Doc in a Markdown File [1]
Create a dedicated Markdown page (e.g., api.md). You can render your OpenAPI schema by declaring a docsify-swagger block and pointing it to your hosted Swagger definition file: [1]
markdown
# API Reference

```docsify-swagger
https://swagger.io
```
Use code with caution.

Method 2: Using docsify-swagger-ui
If you prefer the official, interactive look and feel of the standard Swagger dashboard (including the "Try it out" testing panel), you can use the docsify-swagger-ui GitHub repository plugin. [1, 2]
1. Update index.html
Include both the official Swagger UI assets and the Docsify wrapper plugin in your configuration file:
html
<!-- Swagger UI CSS -->
<link rel="stylesheet" href="//://unpkg.com" />

<!-- Docsify configuration -->
<script>
  window.$docsify = {
    // your config here
  }
</script>

<!-- Docsify and Swagger UI Scripts -->
<script src="//://unpkg.com"></script>
<script src="//://unpkg.com"></script>
<script src="//://unpkg.com"></script>
Use code with caution.
2. Embed the UI Component
In your Markdown file, use a customized utility tag to position the interactive layout:
markdown
# Interactive API Explorer

<div id="swagger-ui"></div>

```javascript
window.ui = SwaggerUIBundle({
  url: 'https://swagger.io',
  dom_id: '#swagger-ui'
});
```
Use code with caution.

---------------
method 2 seems working better

Friday, 31 July 2026

python uvicorn vs wsgi

 Uvicorn is a specific, high-performance web server program, whereas WSGI is an abstract specification defining how Python applications talk to web servers. [1, 2]

To compare them properly, you must look at Uvicorn (an ASGI server implementation) versus WSGI servers (like Gunicorn or uWSGI). The core difference lies in how they handle concurrency: WSGI servers handle requests synchronously using separate processes or threads, while Uvicorn handles them asynchronously via a single-thread event loop. [1, 2, 3, 4, 5]

Core Architecture Comparison
FeatureUvicorn (ASGI Server)WSGI Servers (e.g., Gunicorn)
NatureImplementation (Software)Specification (Standard)
Execution ModelAsynchronous (async/await)Synchronous (Blocking)
ConcurrencySingle-threaded event loop per workerProcess or thread per connection
Supported ProtocolsHTTP/1.1, WebSockets, HTTP/2HTTP/1.1 only
Best Framework FitFastAPI, Starlette, Async DjangoFlask, traditional Django

Key Strengths of Uvicorn
  • High Concurrency: Uses an event loop powered by uvloop to manage thousands of open connections at once.
  • Real-Time Communication: Supports WebSockets natively, removing the need for external event routers.
  • Low Memory Footprint: Handles high traffic using fewer system resources than standard multi-process setups. [1, 2, 3, 4, 5]

Key Strengths of WSGI Servers
  • Stable and Mature: Battle-tested for over a decade in major production environments.
  • Predictable Process Isolation: If a request crashes a worker process, other processes keep running.
  • No Async Overhead: Faster for purely CPU-bound tasks or apps without any asynchronous code. [1, 2, 3, 4, 5]

The Production Compromise
You often do not have to choose between them. In cloud production environments, developers frequently deploy Gunicorn as a process manager to handle master routing and process crashes, while instructing it to use Uvicorn workers (UvicornWorker) to execute the actual async Python code. [1, 2, 3, 4, 5]
Detailed benchmarking and deployment setups can be reviewed via resources like the DeployHQ Server Guide or the Leapcell Server Overview. [1, 2]