Skip to main content

A simple local HTTP server similar to php -S

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

localrun-1.1.6.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

localrun-1.1.6-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file localrun-1.1.6.tar.gz.

File metadata

  • Download URL: localrun-1.1.6.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for localrun-1.1.6.tar.gz
Algorithm Hash digest
SHA256 146d55bbc9aafce7da9e74c840e7baeb43ad6d64c96bca11194c361ccf7669f1
MD5 3b64a674d5915fc7eedc7467c4cd90b6
BLAKE2b-256 243c5958af63514400f8d1ff0d1763b56c73817ed3283df5c27a81a030d0d17b

See more details on using hashes here.

File details

Details for the file localrun-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: localrun-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for localrun-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cbff8326db4a0f7fa8eb1ae86dc7e71b5cc676d88fc7301d1c9370fda902287e
MD5 5846454aca601c22020d1784f0fbe856
BLAKE2b-256 62e429df9d343c6b5b3d9a60c4fdaca0c6cd7f16222880a0dd605eebdf5f631d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page