Skip to content

🔧 enable ansi in cmd#3753

Closed
SayHelloRoman wants to merge 2 commits intofastapi:masterfrom
SayHelloRoman:master
Closed

🔧 enable ansi in cmd#3753
SayHelloRoman wants to merge 2 commits intofastapi:masterfrom
SayHelloRoman:master

Conversation

@SayHelloRoman
Copy link
Copy Markdown

The Windows Console did not support ANSI escape sequences, nor did Microsoft provide any method to enable them.
But in 2016, Microsoft released the Windows 10 version 1511 update which unexpectedly implemented support for ANSI escape sequences, over two decades after the debut of Windows NT.
Windows Console Host used by Command Prompt support for character escape codes used by terminal-based software for Unix-like systems. This is not the default behavior and must be enabled programmatically with the Win32 API via SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING)

Before
Before
After
After

@Kludex
Copy link
Copy Markdown
Member

Kludex commented Aug 23, 2021

That's on uvicorn. You just need to install colorama, and it will be colored.

@SayHelloRoman
Copy link
Copy Markdown
Author

At the expense of colorama, this is an additional addiction that can be dispensed with. Also no matter what ASGI server we are using (gunicorn, Hypercorn, daphne, uWSGI, uvicorn), ansi escape will always be enabled.

@ArcLightSlavik
Copy link
Copy Markdown
Contributor

FastAPI shouldn't touch os related behaviours, this should be dealt with by servers. For example how uvicorn detects that it's on windows and doesn't run uvloop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants