sanic/docs/static_files.md
Eli Uriegas 7554e87374 Fixes doc link extensions from .html to .md
Whoops! Totally missed that all the links pointed to `.html` files
instead of `.md` files
2017-01-19 21:24:08 -06:00

656 B

Static Files

Static files and directories, such as an image file, are served by Sanic when registered with the app.static method. The method takes an endpoint URL and a filename. The file specified will then be accessible via the given endpoint.

from sanic import Sanic
app = Sanic(__name__)

# Serves files from the static folder to the URL /static
app.static('/static', './static')

# Serves the file /home/ubuntu/test.png when the URL /the_best.png
# is requested
app.static('/the_best.png', '/home/ubuntu/test.png')

app.run(host="0.0.0.0", port=8000)

Previous: Deploying

Next: Middleware