https://github.com/marinko-peso/get-port
:snake: Get an available port. Checks first for preferred port in case its available, if not returns random.
https://github.com/marinko-peso/get-port
Last synced: about 2 months ago
JSON representation
:snake: Get an available port. Checks first for preferred port in case its available, if not returns random.
- Host: GitHub
- URL: https://github.com/marinko-peso/get-port
- Owner: marinko-peso
- License: mit
- Created: 2018-09-04T19:42:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T07:21:09.000Z (over 2 years ago)
- Last Synced: 2025-02-28T22:38:50.686Z (2 months ago)
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-port
[](https://github.com/ellerbrock/open-source-badges/)
[](https://github.com/marinko-peso/get-port/blob/master/LICENSE)
[](https://github.com/marinko-peso/get-port/commits/master)
[](https://pypi.org/project/get-port/)
[](https://pypi.org/project/get-port/)
[](http://makeapullrequest.com)Get an available port. Checks first for preferred port in case its available, if not returns random.
Python implementation of the [get-port](https://github.com/sindresorhus/get-port) idea by @[sindresorhus](https://github.com/sindresorhus/).## Installation.
Available via PyPI.
```sh
pip install get-port
```## Usage.
Available in terminal:
```sh
get-port [preferred-port-optional]
```Usage in code:
```python
# Gets the actual port. Send preferred_port to pick if available.
from get_port import get_port
port = get_port(preferred_port)# Check if port is available. Returns tuple: (Boolean, Dict)
from get_port import port_available
is_available = port_available(your_port)# Find random free port. Returns tuple: (Port, Dict)
from get_port import find_free_port
port = find_free_port()
```## License
MIT.