一个有意思的Web API框架:apistar

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:

Django 运行manage.py 报错解决办法(ImportError)

django项目中运行django-bootstrap-toolkit-master\demo_project\manage.py报错

python manage.py runserver 
###
Traceback (most recent call last):  
  File "manage.py", line 2, in <module>  
    from django.core.management import execute_manager  
ImportError: cannot import name execute_manager   

原因是django中没有execute_manager

应将上述import execute_manager 修改为 import execute_from_command_line

附修改后的manage.py

#!/usr/bin/env python  

import os  
import sys  
  
if __name__ == "__main__":  
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")  
  
    from django.core.management import execute_from_command_line  
  
    execute_from_command_line(sys.argv)