나는 우분투를 사용하고 있으며 "webchat"라는 디렉토리를 가지고 있습니다.이 디렉토리 아래에는 webchat.py, webchat.css, webchat.html, webchat.js의 4 개 파일이 있습니다. Tornado의 파일에 HTTP GET 요청을 처리하는 방법은 무엇입니까?
토네이도를 사용하여 HTTP 서버를 생성
, 난 내 파이썬 코드에 루트 ("/")지도 : 'webchat.py'을 다음과 같이 :import os,sys
import tornado.ioloop
import tornado.web
import tornado.httpserver
#http server for webchat
class webchat(tornado.web.RequestHandler):
def get(self):
self.write("Hello, chatter! [GET]")
def post(self):
self.write("Hello, chatter! [POST]")
#create http server
Handlers = [(r"/",webchat)]
App_Settings = {"debug":True}
HTTP_Server = tornado.web.Application(Handlers,**App_Settings)
#run http server
HTTP_Server.listen(9999)
tornado.ioloop.IOLoop.instance().start()
이 http://localhost:9999에 액세스하면 '웹 채팅에 저를 이끌 '핸들러 (클래스 웹캠). 그러나, 나는 webchat.css, webchat.html, webchat.js 같은 'webchat.py'와 같은 디렉토리에있는 다른 파일에 액세스하고 싶습니다.
이 URL은 404 : http://localhost:9999/webchat.html입니다. 이 문제에 대한 가능한 해결책은 무엇입니까? 전용 파일 이름과 상대 경로와 간단한 파일 요청에 대한
보안 문제는 어떻게됩니까? – JulienFr
@jondinham 정말 저를 위해 일해 주셔서 감사합니다 :) –