Skip to main content

FastHttpServer - Simple, Lightweight, and Fast HTTP Server

Overview

FastHttpServer is a pip package that offers a simple, lightweight, and fast HTTP server implemented in Python. This server provides a minimalistic solution for serving static content and handling basic HTTP requests. It is designed to be easy to set up, efficient in serving web content, and accessible as a pip-installable package.

Installation

To install FastHttpServer, use the following pip command:

pip install FastHttpServer

Also make sure the python 'socket' package is installed

Usage

  1. After installation, you can import and run the package:
from FastHttpServer import App
app = App()

or, if App is already reserved:

import FastHttpServer
app = FastHttpServer.App()
  1. Specify the routes of the server

use the app route wrapper and specify the route path. Make sure the proceeding function has a request parameter:

@app.route('/')
def index(request):
    return '<h1>Success!</h1>'

by default the route only accepts GET requests if you want to accept POST or any other and it can allow or disallow cors (default: False), specify in the methods parameter of the route wrapper:

@app.route('/', methods=['GET', 'POST'], allow_cors=True)
def index(request):
    if request['method'] == 'GET':
        return '<h1>Success</h1>'
    else:
        return {'message': 'Success!'}

It automatically detects html and json so no need to use json.dumps!

  1. Run the server:

First, run the server by calling the listen function of 'app':

app.listen()

By default, it runs on localhost port 3000 you can specify parameters to change both of those:

app.listen(PORT=8000, ADDRESS='127.0.0.1')

Open your web browser and navigate to http://localhost:3000 (or the custom port and address you specified). You should see a success or 404 indicating that the server is running.

Notes

  • This server is suitable for serving static content in development and testing environments. For production use, consider security and scalability aspects.

  • FastHttpServer is intentionally kept advanced and minimalistic.

  • Make sure the server listen is called last the routes below it wont work.

Feel free to use and contribute to FastHttpServer. Keep your web serving simple and enjoy the speed!

Release files for FastHttpServer 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FastHttpServer 2.0.1
File Size Uploaded
FastHttpServer-2.0.1.tar.gz 4.0 kB Details

Release files / FastHttpServer-2.0.1.tar.gz

Download URL FastHttpServer-2.0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5dc8c9301bdcfb22427eb6f2a150876cc1574735bee52e236aeac714163fef06
BLAKE2b-256 checksum
How to use checksums
86fc86f779d55610c9cd30adc79d0e5367d05300f1b64e6e07a0ab2a665d533f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release history Release notifications | RSS feed

This release

2.0.1 This release

1 release file

2.0.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page