我以前从未犯过这个错误,我甚至不知道从哪里开始。 这是一个在烧瓶上运行的简单Web应用程序。一切似乎都在应用程序上正常运行,但它一直给我这个错误,即使一切仍然有效。
这里是错误的完整打印:
Exception happened during processing of request from ('127.0.0.1', 61271)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 657, in __init__
self.finish()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 716, in finish
self.wfile.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 283, in close
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
这是我的代码:
app = Flask(__name__)
Bootstrap(app)
app.config['FLASKS3_BUCKET_NAME'] = 'spokane-discount-properties'
s3 = FlaskS3(app)
@app.route("/", methods=['GET', 'POST'])
def index():
context = {
'image': url_for('static', filename= 'property_home.jpeg'),
'heading': 'We sell property - At a discount!',
'landing_video': url_for('static', filename='intro.mp4')
}
form = forms.OptIn()
if form.validate_on_submit():
validate = requests.get(
"https://api.mailgun.net/v3/address/private/validate",
auth=auth,
params={"address": form.email.data})
if validate.json()['did_you_mean'] is not None:
flash('Did you mean {}?'.format(validate.json()['did_you_mean']))
elif validate.json()['is_valid'] == True and validate.json()['is_role_address'] == False and validate.json()['is_disposable_address'] == False:
r = requests.post(
"https://api.mailgun.net/v3/lists/wholesale_buyers@mg.spokanediscountproperties.com/members",
auth=auth,
data={'subscribed': True,
'address': form.email.data})
if r.status_code == 200:
requests.post('https://api.mailgun.net/v3/mg.spokanediscountproperties.com/messages',
auth=auth,
data={"from": 'Matt@SpokaneDiscountProperties.com',
"to": form.email.data,
"subject": "Welcome to Spokane Discount Properties",
"html": open('templates/indoc.html'),
"o:tag": 'indoctrinated'})
flash('Thanks, we will notify you when we have more properties')
else:
flash('You are already subscribed, we will notify you when more properties are available')
else:
flash('Holy guacamole! Best check yo self, this is not a valid email.')
return render_template('index.html', form=form, context=context)