Example #1
0
def show_song_info(song_info):
    print(yate.table_start(1, 10, 10))
    print(yate.table_tr_start())
    print(yate.table_th('songName'))
    print(yate.table_th('artistName'))
    print(yate.table_th('albumName'))
    print(yate.table_th('lrcLink'))
    print(yate.table_th('songLink'))
    print(yate.table_th('showLink'))
    print(yate.table_th('rate'))
    print(yate.table_th('size'))
    print(yate.table_tr_end())

    try:
        print(yate.table_tr_start())
        print(yate.table_td(song_info.songName))
        print(yate.table_td(song_info.artistName))
        print(yate.table_td(song_info.albumName))
        #print(yate.table_td(song_info.lrcLink))
        print(yate.table_td(yate.link(song_info.lrcLink, 'lrcLink')))
        print(yate.table_td(yate.link(song_info.songLink, 'songLink')))
        print(yate.table_td(yate.link(song_info.showLink, 'showLink')))
        #print(yate.table_td(song_info.songLink))
        #print(yate.table_td(song_info.showLink))
        print(yate.table_td(str(song_info.rate)))
        print(yate.table_td(str(song_info.size)))
        print(yate.table_tr_end())
    except IndexError as indexerr:
        print("IndexError:", indexerr)
    print(yate.table_end())
Example #2
0
def make_billboard_list(billboard_list):
    print(yate.table_start(billboard_service.BILLBOARD_SIZE, 10, 10))
    print(yate.table_tr_start())
    print(yate.table_th('rank'))
    print(yate.table_th('language'))
    print(yate.table_th('title'))
    print(yate.table_th('author'))
    print(yate.table_th('album_title'))
    print(yate.table_th('artist_name'))
    print(yate.table_th('listening'))
    print(yate.table_tr_end())

    try:
        #i = 0
        for each in billboard_list:
            print(yate.table_tr_start())
            print(yate.table_td(each.rank))
            print(yate.table_td(each.language))
            print(yate.table_td(each.title))
            print(yate.table_td(each.author))
            print(yate.table_td(each.album_title))
            print(yate.table_td(each.artist_name))
            print(
                yate.table_td(
                    yate.link("play_song.py?song_id=%d" % (int(each.song_id)),
                              'listen')))
            print(yate.table_tr_end())
            #i+=1
    except IndexError as indexerr:
        print("IndexError:", indexerr)
    print(yate.table_end())
Example #3
0
        print(yate.table_td(str(song_info.rate)))
        print(yate.table_td(str(song_info.size)))
        print(yate.table_tr_end())
    except IndexError as indexerr:
        print("IndexError:", indexerr)
    print(yate.table_end())


form_data = cgi.FieldStorage()

#print(setParaAndContext("Content-Type"))
print("Content-type:text/html\n")
print('<html>')
print('<head>')
print('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
print('<title>Billboard List</title>')
print('</head>')
print('<body>')
print('<h2>Billboard List:</h2>')
try:
    song_id = form_data['song_id'].value
except KeyError as kerr:
    print(yate.para('err billboard type...'))

song_info = billboard_service.get_song_info(int(song_id))
show_song_info(song_info)

print(yate.link("/index.html", 'Home'))
print('</body>')
print('</html>')
Example #4
0
        print("IndexError:", indexerr)
    print(yate.table_end())


#print(setParaAndContext("Content-Type"))

print('<html>')
print('<head>')
print('<title>Billboard List</title>')
print('</head>')
print('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
print('<body>')
print('<h2>Billboard List:</h2>')
print(
    yate.link(
        "choose_billboard_list.py?billboard_type=%d" %
        (billboard_service.BILLBOARD_NEW), '新歌'))
print(
    yate.link(
        "choose_billboard_list.py?billboard_type=%d" %
        (billboard_service.BILLBOARD_HOT), '热榜'))
print(
    yate.link(
        "choose_billboard_list.py?billboard_type=%d" %
        (billboard_service.BILLBOARD_ROCK), '摇滚'))
print(
    yate.link(
        "choose_billboard_list.py?billboard_type=%d" %
        (billboard_service.BILLBOARD_JAZZ), '爵士'))
print(
    yate.link(
Example #5
0
cgitb.enable()

import cgi
import service.book_service as book_service
import template.yate as yate

#使用cig.FieldStorage() 访问web请求发送给web服务器的数据,这些数据为一个Python字典
form_data = cgi.FieldStorage()

print("Content-type:text/html\n")
print('<html>')
print('<head>')
print('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
print('<title>Book List</title>')
print('</head>')
print('<body>')
print(yate.header('Book Detail:'))
print(form_data)
try:
    book_name = form_data['bookname'].value
    book_dict = book_service.get_book_dict()
    book = book_dict[book_name]
    print(book.get_html)
except KeyError as kerr:
    print(yate.para('please choose a book...'))
print(yate.link("/index.html", 'Home'))
print(yate.link("/cgi-bin/book_list_view.py", 'Book List'))
print('</body>')
print('</html>')