sanic/docs/getting_started.md

30 lines
792 B
Markdown
Raw Normal View History

2016-10-14 12:51:08 +01:00
# Getting Started
Make sure you have both [pip](https://pip.pypa.io/en/stable/installing/) 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.
2016-10-14 12:51:08 +01:00
1. Install Sanic: `python3 -m pip install sanic`
2. Create a file called `main.py` with the following code:
2016-10-14 12:51:08 +01:00
```python
from sanic import Sanic
from sanic.response import text
2016-10-14 12:51:08 +01:00
app = Sanic(__name__)
2016-10-14 12:51:08 +01:00
@app.route("/")
async def test(request):
return text('Hello world!')
2016-10-14 12:51:08 +01:00
app.run(host="0.0.0.0", port=8000, debug=True)
```
3. Run the server: `python3 main.py`
4. 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](routing.md)