Python web.py Module Basic Application

Source: Internet
Author: User

Python web.py Module Basic Application

System version: CentOS Release 6.5

Installing Pip:yum Install Python-pip

Installing the Web:pip Install Web

Mainly based on the configuration file

1. Getting Started configuration

[email protected] erweima]# Cat weixin.py

#-*-coding:utf-8-*-

Import Web

URLs = (#定义路由, User Access interface

'/', ' index ' #首页, home point

)

Class Index (object):

def GET (self):

Print "detected, page has user access" #浏览器返回打印信息

Return "Welcome to My WebSite" #浏览器获取的界面信息

if __name__ = = ' __main__ ':

Web.application (urls,globals ()). Run ()

Execute script, Verify Results

2. Increase templates Deployment Application

a, Increase Templates

[email protected] erweima]# Cat weixin.py

#-*-coding:utf-8-*-

Import Web

URLs = (#定义路由, User Access interface

'/', ' index ' #首页, home point

)

Render = Web.template.render (' templates ')

Class Index (object):

def GET (self):

return Render.index ()

if __name__ = = ' __main__ ':

Web.application (urls,globals ()). Run ()

B. New directories and files

[email protected] erweima]# Tree

.

├──static

│└──images

│└──zuomian.jpg

├──templates

│└──index.html

├──weixin.py

└──weixin.pyc

Page view

3. Accessories

Upload images yourself

Learn basic HTML knowledge

[email protected]05 erweima]# Cat templates/index.html

<! DOCTYPE HTML public>

<title> Web Test </title>

<style type= "text/css" >

. Shou {width:60%;

height:60px;

Background: #ccccff;

}

*{margin:0;padding:0;}

. box{width:100%;

height:200px;

Background: #ffff33;

}

. Box UL {width:100%;

height:40px;

background:black;}

. Box UL li{

width:100px;

float:left;

list-style:none;

line-height:40px;

color:white;

Font-family: "microsoft Jas black";}

</style>

<body>

<div class= "shou" >

<a href= "http://www.szmc.net/page/index.html" class= "sh1" > Shenzhen Metro official website </a>

</div>

<div class= "box" >

<ul>

<li> Home </li>

<li> Company News </li>

<li> Operations Services </li>

<li> Planning and Construction </li>

<li> Property Development </li>

<li> Invite Investment </li>

</ul>

</div>

</body>

Python web.py Module Basic Application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.