Quickstart
This guide will walk you through creating your first BustAPI application.
Step 1: Create the Application
Create a file named app.py.
Naming
Running the file bustapi.py (same as the package name) will cause import errors.
Stick to app.py or main.py.
from bustapi import BustAPI
app = BustAPI()
@app.route("/")
def home():
return {"message": "Hello from BustAPI!"}
@app.route("/user/")
def greet(name):
return f"Welcome, {name}
"
if __name__ == "__main__":
app.run(debug=True, port=8000)
Step 2: Run the Server
Execute the script in your terminal:
python app.py
You should see a colorful startup log indicating the server is active.
Step 3: Test It
Open your browser or use curl:
- http://127.0.0.1:8000/ - Should return JSON.
- http://127.0.0.1:8000/user/Alice - Should return HTML.
What just happened?
1. @app.route registered your functions with the Rust routing engine.
2. When you hit /, the Rust "hot path" identified the route.
3. Since home() returned a dictionary, BustAPI automatically serialized it to JSON and
set the header Content-Type: application/json.
BustAPI