对于部署在新浪应用引擎SAE上的项目,使用新浪SAE云存储是不错的存储方案。
新浪SAE云存储仅能在SAE环境中正常使用,对它进行简单封装后,可以直接在Flask中使用,项目代码见GitHub上Flask-SaeStorage。
使用示例代码:
复制代码 代码如下:
from flask import Flask
from flask_saestorage import SaeStorage
SAE_ACCESS_KEY = 'SAE Access Key'
SAE_SECRET_KEY = 'SAE Secret Key'
SAE_APP_NAME = 'SAE App Name'
SAE_BUCKET_NAME = 'SAE Bucket Name'
app = Flask(name)
app.config.from_object(name)
sae_storage = SaeStorage(app)
@app.route('/save')
def save():
data = 'data to save'
filename = 'filename'
ret = sae_storage.save(data, filename)
return str(ret)
@app.route('/delete')
def delete():
filename = 'filename'
ret = sae_storage.delete(filename)
return str(ret)
@app.route('/url')
def url():
filename = 'filename'
return sae_storage.url(filename)
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8