2016-10-14 12:51:08 +01:00
|
|
|
# Getting Started
|
|
|
|
|
2016-10-29 19:39:12 +01:00
|
|
|
Make sure you have pip and python 3.5 before continuing.
|
2016-10-14 12:51:08 +01:00
|
|
|
|
2016-10-29 19:39:12 +01:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
Install `sanic` by using the following command:
|
|
|
|
|
|
|
|
`python3 -m pip install sanic`
|
|
|
|
|
|
|
|
It is as easy as that!
|
|
|
|
|
|
|
|
## Hello World!
|
|
|
|
|
|
|
|
Create a file called `main.py` and paste the following code into.
|
2016-10-14 12:58:09 +01:00
|
|
|
```python
|
2016-10-14 12:51:08 +01:00
|
|
|
from sanic import Sanic
|
2016-10-29 19:39:12 +01:00
|
|
|
from sanic.response import text
|
2016-10-14 12:51:08 +01:00
|
|
|
|
|
|
|
app = Sanic(__name__)
|
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
async def test(request):
|
2016-10-29 19:39:12 +01:00
|
|
|
return text("Hello World!")
|
2016-10-14 12:51:08 +01:00
|
|
|
|
|
|
|
app.run(host="0.0.0.0", port=8000, debug=True)
|
|
|
|
```
|
2016-10-29 19:39:12 +01:00
|
|
|
Run it by using `python3 main.py`
|
2016-10-14 12:51:08 +01:00
|
|
|
|
2016-10-29 19:39:12 +01:00
|
|
|
You now have a working Sanic server! To learn more about Sanic, read the following:
|
2016-10-14 13:01:18 +01:00
|
|
|
* [Request Data](request_data.md)
|
2016-10-29 19:39:12 +01:00
|
|
|
* [Routing](routing.md)
|
|
|
|
* [Serving static files](static_files.md)
|