我正在使用 django 运行服务器程序,我想在服务器运行之前和之后运行一些代码。我可以把这些代码放在哪里?
<run function a here>
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^C
<run function b here>
Run Code Online (Sandbox Code Playgroud)
我尝试过print('hello')in app/__init__.py,但发现它运行了两次。为什么?