How to use sanic with other front-end frameworks(react or vue)
If you want to let sanic work with other front-end frameworks like reactjs or vuejs, you should use the following codes:
from sanic import Sanic, response
app = Sanic(name="front-end app")
dist_directory = './dist'
app.static('/', dist_directory)
@app.route("/")
async def index(request):
return await response.file(dist_directory + "/index.html")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8888, debug=True)
or just:
app.static('/', './build/index.html')
app.static('/', './build')