python :有意思的apistar
程序员文章站
2024-03-12 19:36:08
...
https://github.com/encode/apistar#choosing-a-framework
install API Star:
$ pip3 install apistar
Create a new project:
$ apistar new .
app.py
tests.py
$ cat app.py
from apistar import Include, Route
from apistar.frameworks.wsgi import WSGIApp as App
from apistar.handlers import docs_urls, static_urls
def welcome(name=None):
if name is None:
return {'message': 'Welcome to API Star!'}
return {'message': 'Welcome to API Star, %s!' % name}
routes = [
Route('/', 'GET', welcome),
Include('/docs', docs_urls),
Include('/static', static_urls)
]
app = App(routes=routes)
if __name__ == '__main__':
app.main()
下一篇: Linux中常用的一些命令及其含义