Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!coding=utf-8
- import os
- import json
- from flask import Flask
- from flask import request
- from flask import render_template
- from flask import jsonify
- current_dir = os.path.abspath('.')
- app = Flask(__name__, template_folder=current_dir)
- @app.route('/xxx')
- def get_map():
- return render_template('xxx.html')
- @app.route('/edit', methods=['POST'])
- def post_edit():
- params = request.get_json()
- param1 = params.get('param1')
- param2 = params.get('param2')
- # your code here
- debug_data = [
- ['./static/flower.png', './static/flower.png'],
- ['./static/flower.png', './static/flower.png'],
- ['./static/flower.png', './static/flower.png'],
- ]
- debug_points = [
- [10, 10],
- [10, 50],
- [50, 200],
- [50, 10],
- ]
- expected_data = {
- 'images': debug_data,
- 'points': debug_points,
- }
- return jsonify(expected_data)
- @app.route('/edit')
- def get_edit():
- # param1 = int(request.args.get('param1')) # 这个已经是int了
- # param2 = json.loads(request.args.get('param2')) # 这个已经是数组了
- debug_data = [
- ['./static/flower.png', './static/flower.png'],
- ['./static/flower.png', './static/flower.png'],
- ['./static/flower.png', './static/flower.png', './static/flower.png'],
- ]
- debug_points = [
- [10, 10],
- [10, 50],
- [50, 50],
- [50, 10],
- ]
- expected_data = {
- 'images': debug_data,
- 'points': debug_points,
- }
- return render_template('map.html', rows=debug_data, points=debug_points) # 渲染html页面
- if __name__ == '__main__':
- app.run(
- debug=True,
- host='0.0.0.0',
- port=3000,
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement