Github地址:https://github.com/encode/apistar
Install API Star:
$ pip3 install apistar
Create a new project in app.py:
from apistar import App, Route def welcome(name=None): if name is None: return {'message': 'Welcome to API Star!'} return {'message': 'Welcome to API Star, %s!' % name} routes = [ Route('/', method='GET', handler=welcome), ] app = App(routes=routes) if __name__ == '__main__': app.serve('0.0.0.0', 5000, debug=True)
Run app.py
(py3) [root@localhost star]# python app.py * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 684-460-626
Open http://localhost:5000/docs/ in your browser:
原创文章,作者:Tina,如若转载,请注明出处:https://python.01314.cn/201809500.html