커뮤니티

고용노동부, 산업인력공단과 함께하는 강원도 유일한 기업중심 IT전문교육기관 ICT융합캠퍼스만의 특별한교육입니다.
공인 IT숙련기술인의 다양한 접근방법으로 전문가다운 실무교육을 받을 수 있습니다.

Category

교육강좌

WEB WEB2 - Python - 활용 - 조건에 반응하는 앱 만들기

페이지 정보

작성자 관리자 댓글 0건 조회 2,859회 작성일 20-06-03 17:25

본문

활용 - 조건에 반응하는 앱 만들기

수업소개

조건문을 활용해서 URL query string에 id 값이 있는지 여부에 따라서 다르게 동작하는 웹앱을 구현해봅시다.

 

 

강의

 

 

소스코드

변경사항

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/local/bin/python3
print("Content-Type: text/html")
print()
import cgi
form = cgi.FieldStorage()
if 'id' in form:
pageId = form["id"].value
else:
pageId = 'Welcome'
print('''<!doctype html>
<html>
<head>
<title>WEB1 - Welcome</title>
<meta charset="utf-8">
</head>
<body>
<h1><a href="index.py">WEB</a></h1>
<ol>
<li><a href="index.py?id=HTML">HTML</a></li>
<li><a href="index.py?id=CSS">CSS</a></li>
<li><a href="index.py?id=JavaScript">JavaScript</a></li>
</ol>
<h2>{title}</h2>
<p>The World Wide Web (abbreviated WWW or the Web) is an information space where documents and other web resources are identified by Uniform Resource Locators (URLs), interlinked by hypertext links, and can be accessed via the Internet.[1] English scientist Tim Berners-Lee invented the World Wide Web in 1989. He wrote the first web browser computer program in 1990 while employed at CERN in Switzerland.[2][3] The Web browser was released outside of CERN in 1991, first to other research institutions starting in January 1991 and to the general public on the Internet in August 1991.
</p>
</body>
</html>
'''.format(title=pageId))

 

  • 트위터로 보내기
  • 페이스북으로 보내기
  • 구글플러스로 보내기

답변목록

등록된 답변이 없습니다.