%post_id%.html网页404,用于POST请求的烧瓶404

我对烧瓶很新。试图构建一个烧录应用程序,从后端neo4j获取数据并将其以JSON格式发布。最终的目标是使用d3.js进行可视化。但对于初学者,我想把它发布为JSON。用于POST请求的烧瓶404

下面是我的views.py:

import models

from models import Customer

from flask import Flask, request, session, redirect, url_for, render_template, flash,json,jsonify

import os

app = Flask(__name__)

@app.route('/',methods = ['GET','POST'])

def enter_ID():

if request.method == 'POST':

Galactic_ID = request.form['Galactic_ID']

if Customer(Galactic_ID).find():

return redirect(url_for('Customer_relationships',Galactic_ID=request.form.get('Galactic_ID')))

else:

return "Wrong Galactic_ID"

else:

return render_template('Gal.html')

@app.route('/Customer_relationships/')

def Customer_relationships(Galactic_ID):

data = Customer(Galactic_ID).get_relationships():

return render_template('rel.html',Galactic_ID=Galactic_ID,data =json.dumps(data))

if __name__ == '__main__':

host = os.getenv('IP','0.0.0.0')

port = int(os.getenv('PORT',5000))

app.secret_key = os.urandom(24)

app.run(host=host,port=port)

在views.py,客户(Galactic_ID).find()和客户(Galactic_ID).get_relationships()调用的函数找到(个体经营)和get_relationships(个体经营)下Customer类在models.py:下面

当我尝试和运行这个是HTTP调用:

127.0.0.1 - - [29/Jul/2016 17:54:53] "GET/HTTP/1.1" 200 -

127.0.0.1 - - [29/Jul/2016 17:54:56] "POST/HTTP/1.1" 302 -

127.0.0.1 - - [29/Jul/2016 17:54:56] "GET /Customer_relationships/2000000000084001287 HTTP/1.1" 200 -

127.0.0.1 - - [29/Jul/2016 17:54:56] "POST /Customer_relationships HTTP/1.1" 404 -

+0

为什么要将'returnObject'转换成JSON字符串而不是仅仅返回它的目录? –

+0

@davidism现在已修复。 –

+0

@davidism关于如何将returnsObject从models.py传递给views.py? –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值