from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/share', methods=['POST'])
def share_resource():
data = request.get_json()
# 处理数据并存储到数据库
return jsonify({"status": "success", "message": "Resource shared successfully."})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
]]>
new Vue({
el: '#app',
data: {
resource: { name: '', description: '' }
},
methods: {
submitResource() {
fetch('http://localhost:5000/share', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(this.resource)
}).then(response => response.json())
.then(data => alert(data.message));
}
}
});
]]>