Welcome to Asgineer
Asgineer is a minimalistic and asynchronous web framework for Python that is perfect for building lightweight and high-performance web applications. Designed with simplicity and readability in mind, Asgineer empowers developers to build clear and reliable web services using a small set of APIs.
Why Use Asgineer?
Asgineer emphasizes simplicity and speed, making it an excellent choice for developers who want to avoid the overhead of larger frameworks. It’s well-suited for modern Python applications that leverage asynchronous programming paradigms.
Getting Started
Here is an example to get started with Asgineer:
from asgineer import basics @basics.request_handler async def app(request): return "Hello, World!"
You can save this file as app.py
and run it with an ASGI server like uvicorn
:
uvicorn app:app
Dozens of APIS in Asgineer
Below are some of the essential APIs in Asgineer, explained with code snippets:
Handling Query Parameters
from asgineer import basics @basics.request_handler async def app(request): name = request.query.get("name", "Guest") return f"Hello, {name}!"
Handling POST Requests
from asgineer import basics @basics.request_handler async def app(request): data = await request.postjson() # Get JSON body return {"message": f"Received data: {data}"}
Static File Serving
from asgineer.static import StaticFileApp app = StaticFileApp(directory="./static")
Redirects
from asgineer.response import redirect async def app(request): return redirect("https://example.com")
Setting Response Headers
from asgineer.response import Response async def app(request): headers = {"Content-Type": "application/json", "X-Custom-Header": "value"} return Response({"key": "value"}, headers=headers)
Working with Middleware
from asgineer.middleware import Middleware async def my_middleware(next_handler, request): print("Before handler") response = await next_handler(request) print("After handler") return response app = Middleware(my_middleware)
App Example Using Asgineer APIs
Here’s a complete example of a small application that uses several Asgineer APIs:
from asgineer import basics from asgineer.response import Response @basics.request_handler async def app(request): if request.method == "GET": name = request.query.get("name", "Guest") return f"Hello, {name}!" elif request.method == "POST": data = await request.postjson() return Response({"received": data}, headers={"X-App": "AsgineerApp"})
You can deploy this app using any ASGI-compatible server.
Conclusion
Asgineer combines a lightweight architecture with powerful features, making it a great choice for Python web developers who value simplicity without sacrificing performance. Try it out in your next project!