For small sites, a free quota of seven cattle cloud storage is sufficient to provide a stable, fast storage service for the site
Seven Neu Yun storage already has Python SDK, simple encapsulation to it, can be used directly in Flask, project code see GitHub on Flask-qiniustorage.
Using sample code:
Copy Code code as follows:
From flask import Flask
From Flask_qiniustorage import Qiniu
Qiniu_access_key = ' Seven Cattle ACCESS KEY '
Qiniu_secret_key = ' Seven ox SECRET KEY '
Qiniu_bucket_name = ' Seven Cattle space name '
Qiniu_bucket_domain = ' Seven cattle space corresponding domain name '
App = Flask (__name__)
App.config.from_object (__name__)
Qiniu_store = Qiniu (APP)
# or
# Qiniu_store = Qiniu ()
# Qiniu_store.init_app (APP)
# Save the file to seven cows
@app. Route ('/save ')
def save ():
data = ' Data to save '
filename = ' filename '
RET, info = qiniu_store.save (data, filename)
Return STR (ret)
# Delete files in seven-cow space
@app. Route ('/delete ')
def delete ():
filename = ' filename '
RET, info = qiniu_store.delete (filename)
Return STR (ret)
# get the corresponding public URL based on the filename
@app. Route ('/url ')
def URL ():
filename = ' filename '
return Qiniu_store.url (filename)