2
내가 405 얻을 POST 방식을 수용 해달라고 : 내가 서버토네이도
class VendreHandler(BaseHandler):
@tornado.web.authenticated
def post(self):
self.db = conn["essog"]
user = self.get_secure_cookie("mechtari")
info = tornado.escape.json_decode(user)
email = info["email"]
namep = self.get_argument("namep")
prix = self.get_argument("prix")
description = self.get_argument("description")
date = datetime.datetime.now().date()
try:
photo = self.request.files['photo'][0]["body"]
try:
avctype = self.request.files['avatar'][0]["content_type"]
image = Image.open(StringIO.StringIO(buf=avat))
type = image.format
(x, y) = image.size
if x < y:
orientation = "portrait"
else:
orientation = "paysage"
pref = str(time.time())
nomfi = pref.replace(".", "")
nomfich = nomfi + "-" + self.request.files['avatar'][0]["filename"]
self.fs = GridFS(self.db)
avatar_id = self.fs.put(avat, content_type=avctype,filename=nomfich)
except IOError, TypeError:
self.redirect("/error-im")
except KeyError:
nomfich = "nofile"
orientation = "paysage"
avctype = "image/jpeg"
avatar_id = '503ae8553a5f3a0dd8b9cb4c'
self.db.users.update({"email":email}, {"$set":{"produit_up.namep":namep,"produit_up.prix":prix,"produit_up.photo":photo_id, "produit_up.description":description,"produit_up.date":date, "produit_up.vendu":False}})
self.redirect("/success")
및 템플릿에 데이터를 보낼 이후 방법은 허용되지, 그래서 여기서 문제는, 그것은 포스트 방법이다 :
<form id="formvente" name="formvente" method="post" action="/vendre" enctype="multipart/form-data">
{% raw xsrf_form_html() %}
<label for="namep">Le nom du Produit</label>
<input type="text" name="namep" required title="vous devez mettre le nom du produit" placeholder="exemple: peugeot 206">
<label for="prix">Son prix (en Dinars Algérien)</label>
<input type="number" name="prix" required title="vous devez mettre le prix en chiffre (en Dinars Algérien)" placeholder="exemple: 800000">
<label for="photo">Une photo de votre produit</label>
<input name="photo" type="file">
<label for="description">Veuillez donner une déscription du produit (maximum 160 caractères)</label>
<textarea name="description" id="description" rows="3" cols="60" required title="vous devez mettre une petite description" placeholder="escence, 2006, roulant 100000km, toutes options, siege en cuir" onKeyDown="textCounter(document.formvente.description,160)" onKeyUp="textCounter(document.formvente.description, 160)"></textarea>
<meter name="shower" min="1" max="160" value="1"id="shower" low="30" high="140">afficher son etat</meter>
<input id="vendre" type="submit" value="Mettre en Vente"/>
</form>
나는 항상
class VendreHandler(tornado.web.RequestHandler):
def post(self):
namep = 1
prix = 3
description = 43
date = 345
self.db = conn["essog"]
self.db.users.update({"email":email}, {"$set":{"produit_up.namep":namep,"produit_up.prix":prix, "produit_up.photo":photo_id, "produit_up.description":description,"produit_up.date":date, "produit_up.vendu":False}})
self.redirect("/profil#vendu")
있어서 오차 핸들러 단순화 itident는 처리기 내용을 모두 에서 확인합니다 (그렇지 않으면 전자 메일을 찾을 수 없을 때 발생하고 오류가 발생 함)!
- 주의 : Accodion 효과 (CSS3)를 사용했기 때문에 사용하고 있습니까? 페이지는 3 부분으로 구성됩니다 : 프로필, 업로드 제품 및 제품 검색, 그리고 물론 모든 부분에는 자체 핸들러가 있습니다. 그래서 프로파일은 사용자 정보와 아바타를 얻기 위해 GET을 호출 할 것이고, 업로드 제품은 서버에 제품 정보를 쓰는 POST를 만들 것이며 마지막으로 검색은 제품을 검색하기 위해 서버에 GET을 줄 것이다. 그래서, 내가 실수하고 있니?
다행히 해결했지만 나중에 URLSpec을 포함시켜야합니다 .-) –
감사합니다. 초보자입니다. –
나는 똑같습니다. 이 문제는 아무 것도 해결하지 못합니다. 오류의 출처는 기타 여야합니다. – Sebastialonso