更新时间:2023-11-22 20:52:28
您可能需要考虑Simon Willison的图书馆:
从 readme :
djng是一个依赖宏框架的微框架(Django )。
我对mi的定义cro框架:可以让您在单个模块中创建一个完整的
Python Web应用程序:import djng
def index(request):
return djng.Response('Hello,world')
如果__name__ =='__main__':
djng。 serve(index,'0.0.0.0',8888)[...]
I want to write a very small Django application in a single file, requiring all the appropriate modules and stuff, and then be able to run that as a normal Python script, like this:
$ python myapp.py
You can assume I won't render HTML, so I don't need templates (I'll return JSON or some other auto-generated string).
You might want to consider Simon Willison's library:
From the readme:
djng is a micro-framework that depends on a macro-framework (Django).
My definition of a micro-framework: something that lets you create an entire Python web application in a single module:
import djng def index(request): return djng.Response('Hello, world') if __name__ == '__main__': djng.serve(index, '0.0.0.0', 8888)
[...]