-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
36 lines (31 loc) · 1.1 KB
/
views.py
File metadata and controls
36 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from app import app
from flask import redirect, jsonify
from flask.templating import render_template
import json,main
from flask.globals import request
@app.route("/")
def index():
#form = submitForm.subForm()
return render_template("index.html")
@app.route("/baidu")
def baidu():
return redirect("https://www.baidu.com/")
@app.route("/json",methods =["GET","POST"])
def getjson():
f = open("app/templates/data.json")
data = json.load(f)
# data = {"nodes":[{"name":"1","value":20,"symbolSize": 60,"category": 0},{"name":"2","value":20,"symbolSize": 60,"category": 1}],"links":[{"source" : '1',"target" : '2'}]}
#print data
return jsonify(data)
@app.route("/get_data",methods =["GET","POST"])
def submit():
if request.method == 'POST':
# topic = request.get_json()["search"]
#main.getdata(topic)
a = request.get_data()
data= json.loads(a)
topic = data["topic"]
result = main.getdata(topic)
#print data
return jsonify(result)
return render_template("index.html")