1
0
Fork 0
forked from github/pelican

Use pelican.server class in invoke template

This commit is contained in:
Deniz Turgut 2018-11-25 21:43:40 +03:00
commit a3b256db1e

View file

@ -4,14 +4,10 @@ import os
import shutil import shutil
import sys import sys
import datetime import datetime
try:
import socketserver
except ImportError:
import SocketServer as socketserver
from invoke import task from invoke import task
from invoke.util import cd from invoke.util import cd
from pelican.server import ComplexHTTPRequestHandler from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
CONFIG = { CONFIG = {
# Local path configuration (can be absolute or relative to tasks.py) # Local path configuration (can be absolute or relative to tasks.py)
@ -61,12 +57,12 @@ def regenerate(c):
@task @task
def serve(c): def serve(c):
"""Serve site at http://localhost:8000/""" """Serve site at http://localhost:8000/"""
os.chdir(CONFIG['deploy_path'])
class AddressReuseTCPServer(socketserver.TCPServer): class AddressReuseTCPServer(RootedHTTPServer):
allow_reuse_address = True allow_reuse_address = True
server = AddressReuseTCPServer( server = AddressReuseTCPServer(
CONFIG['deploy_path'],
('', CONFIG['port']), ('', CONFIG['port']),
ComplexHTTPRequestHandler) ComplexHTTPRequestHandler)