2016-10-24 09:21:06 +01:00
|
|
|
# Static Files
|
|
|
|
|
|
|
|
Both directories and files can be served by registering with static
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```python
|
|
|
|
app = Sanic(__name__)
|
|
|
|
|
|
|
|
# Serves files from the static folder to the URL /static
|
2016-10-25 10:45:28 +01:00
|
|
|
app.static('/static', './static')
|
2016-10-24 09:21:06 +01:00
|
|
|
|
|
|
|
# Serves the file /home/ubuntu/test.png when the URL /the_best.png
|
|
|
|
# is requested
|
2016-10-25 10:45:28 +01:00
|
|
|
app.static('/the_best.png', '/home/ubuntu/test.png')
|
2016-10-24 09:21:06 +01:00
|
|
|
|
|
|
|
app.run(host="0.0.0.0", port=8000)
|
|
|
|
```
|