Getting Started with Xyra
Welcome to Xyra! This guide will help you create your first web application with the Xyra framework in minutes.
Prerequisites
Before you begin, make sure you have:
- Python 3.11 or newer
- The `pip` package manager
- A basic knowledge of Python
Installation
First, install Xyra using pip in your terminal.
Bash
pip install xyra
For more details, see the Installation page.
Your First Application
Let's create a simple web application that displays "Hello, Xyra!".
1. Create the Application File
Create a new file named app.py and add the following code:
Python
from xyra import App, Request, Response
app = App()
@app.get("/")
def home(req: Request, res: Response):
res.json({"message": "Hello, Xyra!"})
if __name__ == "__main__":
app.listen(8000)
2. Run the Application
Run the application with the following command:
Bash
python app.py
You will see output like this:
Output
🚀 Xyra server running on http://0.0.0.0:8000
3. Access the Application
Open your browser and visit http://localhost:8000. You will see a JSON response:
JSON
{
"message": "Hello, Xyra!"
}