app = Sanic(__name__) model_map = {} @app.route("/update", methods=['GET', 'POST']) async def update(request): global n n = len(open("./new_tree.yml").read()) return text('OK') @app.route("/files", methods=['GET', 'POST']) async def post_json(request): test_file = request.files.get('file') basepath = os.path.dirname(__file__) file_path = os.path.join(basepath, './', test_file.name) with open(file_path, 'wb') as f: f.write(test_file.body) return redirect('/update') from appzoo import App _app = App() _app.app = app def predict(**kwargs): return n _app.add_route('/model', predict) _app.run()
@task(timedelta(hours=1), time(hour=1, minute=30)) async def foo_bar(_): """Runs the function every 1 hours after 1:30.""" print("Foo", datetime.now()) await asyncio.sleep(1) print("Bar") @task(timedelta(minutes=2), timedelta(seconds=10)) def baz(_): """Runs the function every 2 minutes after 10 seconds.""" print("Baz", datetime.now()) @task(start=timedelta(seconds=10)) def another(_): """Run the function after 10 seconds once.""" print("another", datetime.now()) from appzoo import App app_ = App() app_.app = app app_.add_route('/', lambda **kwargs: d) # values.get_value() if __name__ == "__main__": app.run(host='0.0.0.0', port=5000, debug=True, workers=4)