Git Product home page Git Product logo

flask_newsapi's Introduction

跨域问题来源于JavaScript的"同源策略",即只有协议+主机名+端口号 (如存在)相同,才允许相互访问。
也就是说JavaScript只能访问和操作自己域下的资源,不能访问和操作其他域下的资源。
跨域问题是针对JS和ajax的,html本身没有跨域问题。

后端解决跨域问题
pip install flask-cors
使用第三方扩展 exts中创建
from flask_cors import CORS
cors= CORS()
与app进行绑定即可
cors.init_app(app=app,supports_credentials=True)


蓝图与api配合使用
user_bp = Blueprint('user', __name__)
蓝图绑定api 蓝图注册到app上
api = Api(user_bp)
app.register_blueprint(user_bp)
# 定义api
class xxxxApi(Resource):
    pass
# 绑定路由
api.add_resource(xxxxApi,'/xxxx')


在OAuth协议中,token是在输入了用户名和密码之后获取的,利用这个token可以拥有查看或者操作相应的资源的权限。
有这些权限,是因为服务器知道你是谁以后赋予你的,所以token,其实就是你的一个“代表”,或者说完全能代表你的“通行证”。

flask_newsapi's People

Contributors

zxy1013 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.