Skip to main content

A simple local server to run your Python applications.

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

  1. Start Server on Default Host and Port (127.0.0.1:8000)

    localrun
    
  2. Start Server on Specified Host and Port

    localrun --host 127.0.0.1 --port 8000
    
  3. 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.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

localrun-1.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: localrun-1.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for localrun-1.1.2.tar.gz
Algorithm Hash digest
SHA256 fd52a5e4249dfb8cbe7507165556ae512d3d7aa2d6f90e072d1b07a77b9fe383
MD5 70650c8b28d35bfcf7eb62ce5c940711
BLAKE2b-256 fc328945c23ed4859750c4ddaafadb771cf22626aa2e40c392520475cb24e7af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: localrun-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for localrun-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87cfd58fde6ffd0066c33a4003c1a7912e3e6a6246b45c114418bbfff651adf1
MD5 0936412ffd2b999fb45d4206561ded71
BLAKE2b-256 4a64028b8b2661ee3a2069f8badd9055279ea9f9ecc6a48e6d4cda08341bf641

See more details on using hashes here.

Supported by

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