flask make response
This commit is contained in:
parent
a891e77d40
commit
55d587f6d0
|
@ -17,7 +17,7 @@ logging.getLogger('requests').setLevel(logging.WARNING)
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import json
|
||||||
import httplib
|
import httplib
|
||||||
import traceback
|
import traceback
|
||||||
from flask import Flask, request, render_template, url_for, redirect, session, flash, g
|
from flask import Flask, request, render_template, url_for, redirect, session, flash, g
|
||||||
|
@ -129,6 +129,19 @@ class Application(Flask):
|
||||||
|
|
||||||
print >> sys.stderr, ' * Ready in %.2fms' % (1000.0 * (time.time() - start_time))
|
print >> sys.stderr, ' * Ready in %.2fms' % (1000.0 * (time.time() - start_time))
|
||||||
|
|
||||||
|
def make_response(self, rv):
|
||||||
|
if rv is None:
|
||||||
|
rv = '', httplib.NO_CONTENT
|
||||||
|
elif not isinstance(rv, tuple):
|
||||||
|
rv = rv,
|
||||||
|
|
||||||
|
rv = list(rv)
|
||||||
|
|
||||||
|
if isinstance(rv[0], (list, dict)):
|
||||||
|
rv[0] = self.response_class(json.dumps(rv[0]), mimetype='application/json')
|
||||||
|
|
||||||
|
return super(Application, self).make_response(tuple(rv))
|
||||||
|
|
||||||
|
|
||||||
class RegexConverter(BaseConverter):
|
class RegexConverter(BaseConverter):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -70,8 +70,6 @@ def delete(name):
|
||||||
@blueprint.route("/wiki/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
||||||
@blueprint.route("/wiki/_create/<name>", methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/<name>", methods=['GET', 'POST'])
|
||||||
def create(name):
|
def create(name):
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
g.current_wiki.write_page(request.form['name'],
|
g.current_wiki.write_page(request.form['name'],
|
||||||
request.form['content'],
|
request.form['content'],
|
||||||
|
|
Loading…
Reference in a new issue