현재 디렉토리를 웹서버로 만들어주는 명령입니다.
커맨드창에서 다음 명령을 실행합니다.
python -m SimpleHTTPServer
포트를 지정할 수 있습니다.
python -m SimpleHTTPServer 9000
Serving HTTP on 0.0.0.0 port 9000 ...
과 같은 메시지가 나오면 작동하는 것입니다.
https://docs.python.org/2/library/simplehttpserver.html
2019년 12월 24일 화요일
2019년 8월 10일 토요일
python mysql mysqlclient MySQLdb
설치
pip install mysqlclient모듈 로드
import MySQLdb데이터베이스 연결
connection = MySQLdb.connect(
user="username",
passwd="password",
host="localhost",
db="dbname",
charset="utf8"
)
커서 추출
cursor = connection.cursor()
업데이트 쿼리
# create table note ( title varchar(100), content text )
cursor.execute("insert into note(title, content) values(%s,%s)", ("a", "b"))
connection.commit()
조회 쿼리
sql = "select * from note where title=%s"
cursor.execute(sql, ('a',))
for row in cursor.fetchall():
print(row) # ('a', 'b')
Dict 커서로 변경
cursor = connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute(sql, ('a',))
for row in cursor.fetchall():
print(row) # {'title': 'a', 'content': 'b'}
print(row['title'], row['content']) # a b
연결 종료
connection.close()
라벨:
mysql,
mysqlclient,
MySQLdb,
python
2019년 8월 9일 금요일
javascript date clone and equal comparison
d1 = new Date()
d2 = new Date(d1)
d3 = new Date(d1.getTime())
d1.getTime() === d2.getTime()
d1.valueOf() === d3.valueOf()
https://stackoverflow.com/questions/1090815/how-to-clone-a-date-object/11051108#11051108
https://stackoverflow.com/questions/7244513/javascript-date-comparisons-dont-equal
d2 = new Date(d1)
d3 = new Date(d1.getTime())
d1.getTime() === d2.getTime()
d1.valueOf() === d3.valueOf()
https://stackoverflow.com/questions/1090815/how-to-clone-a-date-object/11051108#11051108
https://stackoverflow.com/questions/7244513/javascript-date-comparisons-dont-equal
라벨:
clone,
compare,
comparison,
date,
equal,
equals,
javascript
2019년 4월 24일 수요일
(Roundcube) Mailbox doesn't exist: trash
(Roundcube) Mailbox doesn't exist: trash
지운 편지함이 없는 상태에서 메일을 지우면 위와 같이 에러가 발생합니다.
폴더 관리에서 Trash 폴더를 생성해주면 해결됩니다.
폴더 관리에서 Trash 폴더를 생성해주면 해결됩니다.
피드 구독하기:
글 (Atom)



