LocalRun
LocalRun is a Python package that provides an easy way to run a simple HTTP server locally, similar to the php -S command. It supports both silent and non-silent modes for logging HTTP requests.
Installation
You can install localrun using pip :
pip install localrun
Command-Line Usage
You can run the server directly from the command line using the following syntax :
Start Server with Host and Port
localrun --host <HOST> --port <PORT>
Start Server with Silent Mode
To run the server in silent mode, which suppresses log output :
localrun --host <HOST> --port <PORT> --silent
Examples
Start Server on Default Host and Port (127.0.0.1:8000)
localrun
Start Server on Specified Host and Port
localrun --host 127.0.0.1 --port 8000
Start Server with Silent Mode
localrun --host 127.0.0.1 --port 8000 --silent
Programmatic Usage
You can also use localrun as a module in your Python scripts.
Example Script
Here's how to start the server programmatically :
# example_script.py
import localrun
# Start the server in silent mode
running_address = localrun.run_server('127.0.0.1', 8000, silent=True)
# Print the running address
print(f"Running port is: {running_address}")
Running Without Silent Mode
To start the server without silent mode:
# example_script.py
import localrun
# Start the server
running_address = localrun.run_server('127.0.0.1', 8000)
# Print the running address
print(f"Running port is: {running_address}")
Logging Format
In non-silent mode, the server logs HTTP requests in the following format:
localrun - - [25/Oct/2024 23:01:50] "GET /new/instance/ HTTP/1.1" 200 -
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for localrun 1.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| localrun-1.1.8.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| localrun-1.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / localrun-1.1.8.tar.gz
| Download URL | localrun-1.1.8.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd1c66d380054dffe8aeaf2f0c837d34460bc60c39333885119228c84431756e
|
|
BLAKE2b-256 checksum How to use checksums |
657ea6d4fbd62864e63ca4e70881f9426bcb79a16a7ac479ad282e57e481aba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / localrun-1.1.8-py3-none-any.whl
| Download URL | localrun-1.1.8-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af8cd98dac3fc35122156b2e3ef745735489ce232b0912008ff3b1efd468dca9
|
|
BLAKE2b-256 checksum How to use checksums |
65fd2ed79a7676a49f5f302081eadf75e774bd99c2c6a4e099eb4b7a3be2d1b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|