A simple-to-use framework for http and https servers
Project description
🌐 HttPython
A simple-to-use http and https server, simillar to flask, in python.
✅ To-do
- HTTP and HTTPS server class
- Request class
- Document class
- Python code execution in html
- MIME type in Document class
- Default headers per server
- Per host handler
❓ How to use
from httpython.servers import HTTP_Server
from httpython import RequestMethod
# Define the port and host
host, port = "127.0.0.1", 80
# Instanciate the server object
server = HTTP_Server(host, port)
#For HTTPS servers, use HTTPS_Server(host, port, certificate_path, private_key_path)
# Create an handler for requests
@server.method(RequestMethod.GET, route="*", host="*") # Using the route and host parameters as '*' will use this handler as a fallback for the GET method.
def GET_Handler(request):
# do stuff
return Request.response(
500, # Status code
"Not Implemented", # Message
{"Server": "httpy/2.0", "Connection": "closed"}, # Headers
b"" # Body
)
@server.method(RequestMethod.GET, route="/api/", host="*")
def API_Handler(request):
# do stuff
return Request.response(
500, # Status code
"Not Implemented", # Message
{"Server": "httpy/2.0", "Connection": "closed"}, # Headers
b'{"foo": "bar"}' # Body
)
# Run the server
server.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
httpython-0.2.7.tar.gz
(5.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpython-0.2.7.tar.gz.
File metadata
- Download URL: httpython-0.2.7.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35ce92544dd08f08278bbccdd081c4433be18136830851062b5c44665bfd52b5
|
|
| MD5 |
15614d4787ee692e5ff66f2c2c377b6d
|
|
| BLAKE2b-256 |
7b030adf6f9af2730ac8d9ca73f0682fc9264083150cf2fbd825bc18ea494976
|
File details
Details for the file httpython-0.2.7-py3-none-any.whl.
File metadata
- Download URL: httpython-0.2.7-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66b2b6963c89ca25cf0ad064bb93203d1a9239d60ed179719fc9df65c53613d2
|
|
| MD5 |
37fe8a14d76700c202678a3085497d95
|
|
| BLAKE2b-256 |
b99241a6b12060109bec2ddfd592979cb6ac2359739c9e9824322c6904cc04c1
|