A Python-centric micro-framework for building web applications
Project description
PyKite: A research and development initiative for crafting a Python-centric micro framework.
Features
-
Route Definition: Define routes using the
@app.route(path)
decorator. -
HTTP Request Handling: Create handler functions for each route to process and respond to incoming HTTP requests.
-
Development Server: Start a development server with a single command, making it easy to test your application locally.
-
Basic Error Handling: Includes a default 404 response for routes that are not found.
Installation
To get started with PyKite, follow these steps:
pip install pykite
Run the application
- Create a Python script for your web application using PyKite. Define routes and handlers as needed.
- Run your application using the
run
method:
from pykite import PyKite
from pykite.http.response import Response
# Create a PyKite application
app = PyKite(debug=True)
# Define a route for the '/' path
@app.route('/')
def index(request, response):
"""Respond with a JSON object containing the message "Hello, World!" to all requests to the '/' path."""
data = {"message": "Hello, World!"}
response = Response(data=data, status=200)
return response
@app.route('/hello/{name}')
def hello(request, response, name):
""" Took a name from the URL and responds with a friendly greeting in JSON."""
data = {"message": f"Hello, {name}"}
response = Response(data=data, status=200)
return response
# Run the application
if __name__ == "__main__":
app.run()
- Access your application in a web browser at http://localhost:8000.
License
This project is licensed under the MIT License.
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
Built Distribution
File details
Details for the file pykite-0.3.0.tar.gz
.
File metadata
- Download URL: pykite-0.3.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4bfcb4d8e903ee58ec3429aade347b5720307868e3a782d997fc3c098f65988 |
|
MD5 | 308a8c031072cb389417a99a404f1495 |
|
BLAKE2b-256 | 6077af86c0810e72199056afe9ddaac8ec5fcf2fef22c28630aa3e2865f29002 |
File details
Details for the file pykite-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: pykite-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d12ed799ca08521db4a1e006aa750cef6afcf6eb1c51a21c6fd8b6289a31fa |
|
MD5 | 92ce17ae845c3186b51fba8a8fc0b4b6 |
|
BLAKE2b-256 | dfb60e8d184c9c8c5c3a812fd3519f30841f0ef74ad6fe76a37697ba4dddf734 |