.wsgi File Extension
.wsgi file contains, how to open and deploy it safely, how Poly supports it, and when another Python entry point fits better. File extension details for .wsgi
Partial Support| File type | Python WSGI application entry-point script |
|---|---|
| MIME type | |
| Encoding | Unicode Python source text, UTF-8 by default; a source encoding declaration can select another codec |
| Operating systems | Windows, macOS, Linux |
| Opens with | Visual Studio Code, PyCharm, Apache mod_wsgi, Any text editor |
| Poly support | Partial. Poly stores .wsgi files; Python source features require the text/x-python media type. |
| Indexed by Poly | Partial. Correctly classified source is indexed for exact and semantic search; otherwise the filename remains searchable. |
| Preview in Poly | Partial. A .wsgi file supplied as text/x-python opens in Poly's code editor. |
| Poly agent | Partial. The Poly agent can read correctly classified source without executing it. |
What kind of file is a .wsgi?
A .wsgi file is usually a short Python deployment script that exposes a WSGI application to a compatible web server. It often imports a framework application and assigns it to a variable named application. The WSGI server then calls that object for each request.
The suffix is a convention, not part of the WSGI specification. PEP 3333 defines the interface between a Python web application and a server, but deliberately leaves the deployment mechanism to the server.1 Apache mod_wsgi commonly demonstrates entry-point files such as myapp.wsgi, while noting that its script directive accepts any extension or none.2
Desktop MIME databases commonly classify .wsgi as text/x-python. That media type is not registered with IANA, and another system may report the same file as text/plain.3 There is no magic number. Check for readable Python syntax and the expected application callable rather than trusting the filename alone.
.wsgi does not create a working deployment entry point. The script still needs to import or define a WSGI-compatible callable, and the server must be configured to load it.How do I open a .wsgi on my computer?
Open .wsgi source in any text editor on Windows, macOS, or Linux. Visual Studio Code and PyCharm can provide Python highlighting and diagnostics, although you may need to select Python language mode manually when the editor does not recognize the suffix.
Do not double-click an unfamiliar file or run it merely to inspect it. A .wsgi script is executable Python and can read secrets, alter files, start processes, or access the network. For deployment, point the chosen WSGI server at the script according to that server's documentation. With Apache mod_wsgi, WSGIScriptAlias maps a URL path to the script's full filesystem path.2
Poly support for .wsgi
Poly stores, syncs, shares, versions, and finds .wsgi files by name. Poly does not currently infer Python source from the .wsgi suffix alone.
When a file is supplied as text/x-python, it opens in Poly's code editor and its readable source is available to exact search, semantic search, and the Poly agent. Poly does not execute the application, import its project, or observe live request behavior. Include related modules and configuration when you want the agent to reason about the complete deployment.
.wsgi file.History of .wsgi
Phillip J. Eby's original WSGI proposal, PEP 333, was created on December 7, 2003. Its goal was a simple, universal interface between Python web servers and applications.4 PEP 3333 followed in 2010 with Python 3 guidance and accumulated clarifications while retaining WSGI 1.0 compatibility.1
The .wsgi filename convention grew from server deployment practice rather than the specification. It remains especially associated with Apache mod_wsgi script files, but WSGI servers can instead accept import strings, configuration, or other entry-point mechanisms.
Working with .wsgi and alternatives
Keep the script small. Import the real application, perform only essential setup, and avoid embedding secrets. Heavy application code belongs in normal Python modules where editors, tests, and packaging tools handle it naturally.
| Goal | Better fit | Tradeoff |
|---|---|---|
| Deploy through Apache mod_wsgi | .wsgi entry-point script | Clear server boundary, but tied to that deployment convention |
| Let a server import an application | .py module plus module:callable configuration | More portable across servers, but syntax varies by server |
| Use async-native protocols or WebSockets | ASGI application | Requires an ASGI-compatible framework and server |
| Inspect or publish configuration | Documented text or environment configuration | Safer separation, but not an executable entry point |
Changing .wsgi to .py only changes the filename. A real migration must also update the server configuration and preserve the callable, imports, environment, and working-directory assumptions.
Footnotes
- Python Software Foundation. PEP 3333: Python Web Server Gateway Interface v1.0.1. The specification defines the server and application sides and leaves delivery of the application object to the server or gateway. ↩ ↩2
- mod_wsgi. WSGIScriptAlias. The documentation maps a URL to a script path and describes
.wsgias a convention rather than a requirement. ↩ ↩2 - freedesktop.org. Shared MIME Info Database: Python Source Definitions. The database associates
.wsgiwithtext/x-pythonand also checks Python interpreter lines. ↩ - Python Software Foundation. PEP 333: Python Web Server Gateway Interface v1.0. The original proposal was created on December 7, 2003 and was later superseded by PEP 3333. ↩