Skip to content

how to Syntax Highlighter Python #242

@andyhebear

Description

@andyhebear

how to Syntax Highlighter Phyton
like this:
import sys
import os
import mimetypes
from wsgiref import simple_server, util

def app(environ, respond):

fn = os.path.join(path, environ['PATH_INFO'][1:])
if '.' not in fn.split(os.path.sep)[-1]:
    fn = os.path.join(fn, 'index.html')
type = mimetypes.guess_type(fn)[0]

if os.path.exists(fn):
    respond('200 OK', [('Content-Type', type)])
    return util.FileWrapper(open(fn, "rb"))
else:
    respond('404 Not Found', [('Content-Type', 'text/plain')])
    return [b'not found']

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions