Hi,
I wish to pass an argparse argument to a function with decorators. What is the strategy here? How can I achieve this without global variables?
#!/usr/bin/env python3
from sanic import Sanic, views, response
import os
import argparse
app = Sanic(__name__)
@app.route('/<var:var>')
async def get(self, request, var):
print(path)
return response.text(var)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--path",
help="Set the server root path",
action="store")
args = parser.parse_args()
app.run(host='0.0.0.0', port=8000)
I also tried using the view HTTPMethodView
but without success