6176964bdf
* Reorder and clarify the 'Request Data' guide, adding a section on RequestParameters * Clarify routing guide, adding introduction and HTTP types sections * Clarify the use-cases of middleware * Clean up formatting in the exceptions guide and add some common exceptions. * Fix formatting of blueprints and add use-case example. * Clarify the class-based views guide * Clarify and fix formatting of cookies guide * Clarify static files guide * Clarify the custom protocols guide. * Add more information to the deploying guide * Fix broken list in the community extensions list. * Add introduction and improve warning to contributing guide * Expand getting started guide * Reorder guides and add links between them * Standardise heading capitalisation
794 B
794 B
Getting Started
Make sure you have both pip and at
least version 3.5 of Python before starting. Sanic uses the new async
/await
syntax, so earlier versions of python won't work.
- Install Sanic:
python3 -m pip install sanic
- Create a file called
main.py
with the following code:
from sanic import Sanic
from sanic.response import text
app = Sanic(__name__)
@app.route("/")
async def test(request):
return text('Hello world!')
app.run(host="0.0.0.0", port=8000, debug=True)
- Run the server:
python3 main.py
- Open the address
http://0.0.0.0:8000
in your web browser. You should see the message Hello world!.
You now have a working Sanic server!
Next: Routing