컴퓨터/Python

생활코딩29강

풍경소리^^ 2019. 1. 27. 20:12

==========29.Pypi,패키지 매니저 PIP

----------검색python html sanitizer

https://pypi.org/

패키지 매니져

----------

cmd

pip help install

pip install html-sanitizer

----------index.py

import cgi, os, view, html_sanitizer

sanitizer=html_sanitizer.Sanitizer()#소문자로 하세요

    # description=description.replace('<','<')
    # description=description.replace('>','>')
    description=sanitizer.sanitize(description)

----------

if 'id' in form:
    title=pageId=form["id"].value

    title=sanitizer.sanitize(title)

else:
    title=pageId='Welcome'

----------

'''.format(
    title=title,

----------view.py

import os, html_sanitizer

def getList():
    sanitizer=html_sanitizer.Sanitizer()#소문자로 하세요
    files=os.listdir('data')
    #print(files)
    listStr=''
    for item in files:
        item=sanitizer.sanitize(item)#소문자로 하세요
        listStr=listStr+'<li><a href="index.py?id={name}">{name}</a></li>'.format(name=item)
    #print(listStr)
    return listStr

----------