NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


#####################################################################
### Assignment skeleton
### You can alter the below code to make your own dynamic website.
### The landing page for assignment 3 should be at /assignment3/
#####################################################################

from bottle import *

status = ''

rates_series = {}
favour_series = {}
dizi_dict= {'leyla':
{ 'title' : 'Leyla ile Mecnun',
'radio': 'rate1',
'rating': 0,
'usercount':0,
'character': {
'Mecnun Cinar' : {
'value' : 'Mecnun Cinar',
'rating':0,
},
'Ismail Abi' : {
'value' : 'Ismail Abi',
'rating':0,
},
'Erdal Baggal' : {
'value' : 'Erdal Baggal',
'rating':0,
},
'Hirsiz Yaviz' : {
'value' : 'Hirsiz Yaviz',
'rating':0,
}
}
},


'kardes':
{ 'title' : 'Kardes Payi',
'radio': 'rate2',
'rating': 0,
'usercount':0,
'character': {
'Metin' : {
'value' : 'Metin',
'rating':0,
},
'Ali' : {
'value' : 'Ali',
'rating':0,
},
'Feyza' : {
'value' : 'Feyza',
'rating':0,
},
'Hilmi' : {
'value' : 'Hilmi',
'rating':0,
}
}


},
'behzat':
{ 'title' : 'Behzat C.',
'radio': 'rate3',
'rating': 0,
'usercount':0,
'character': {
'Behzat C.' : {
'value' : 'Behzat C.',
'rating':0,
},
'Harun' : {
'value' : 'Harun',
'rating':0,
},
'Hayalet' : {
'value' : 'Hayalet',
'rating':0,
},
'Eylul' : {
'value' : 'Eylul',
'rating':0,
}
}
}
}

def htmlify(title, content):
page = """<!DOCTYPE html>
<html>
<head>
<title>""" + title + """</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/static/style.css">
<script type="text/javascript" script-name="comfortaa" src="http://use.edgefonts.net/comfortaa.js"></script>
</head>
<body>
""" + content + """
</body>
</html>"""
return page

def a3_index():
return htmlify("My lovely website","This is going to be an awesome website, when it is finished.")

def website_index():
return htmlify('My lovely homepage',
"""
<!-- p><a href="/assignment1/">Click for my assignment 1.</a></p -->
<!-- p><a href="/assignment2/">Click for my assignment 2.</a></p -->
<p><a href="/assignment3/">Click for my assignment 3.</a></p>
""")
def Static(filename):
return static_file(filename, root='static')


def choose():
global status
a = """
<form action="/domestic/" method="post">
<h3 class="login-text">First name:</h3>
<input class="name" type="text" name="firstname">
<br>
<h3 class="login-text">Surname:</h3>
<input class="name" type="text" name="surname"><br>
<br>
<input class="submit" name="submit" type="submit" id="submit" value="Submit"></form>""" + status;status = ''; return htmlify('Index page', a)


def calistir():
global username
username = request.forms.get('firstname')


def domestic_page():
d = """<p class="choose-text">Choose one of the domestic series:</p><form method="POST" action="#">
<select class="selector" name="series">
<option value="leyla">Leyla ile Mecnun</option>
<option value="kardes">Kardes Payi</option>
<option value="behzat">Behzat C.</option>
</select>
<br><br>
<input class="submit" name="submit" type="submit" id="submit" value="Submit">
</form>"""
return htmlify('Domestic Series', d)






def calistir2():
global selection2
selection2 = request.forms.get('series')
redirect(selection2)


status = ''
def series_page(name):
serie = dizi_dict[name]

character = ''
for c in serie['character'].values():
character += '<input type="checkbox" name="{name}" value="{value}">{value}n'.format(name='name', value=c['value'])

global status
e = """<form method="POST" action="#" ><p class="choose-text">What is your rate?</p>
<p class="character-text"><input type="radio" name="{rate}" value="1" checked>1
<input type="radio" name="{rate}" value="2">2
<input type="radio" name="{rate}" value="3">3
<input type="radio" name="{rate}" value="4">4
<input type="radio" name="{rate}" value="5">5</p>
<p class="choose-text">What is your favourite character(s)?</p>
<p class="character-text">{checkbox}</p>
<input class="submit" name="submit" type="submit" id="submit" value="Submit">
</form> <br />""".format(rate=serie['radio'], checkbox=character) + status
z = """<br><a class="result-text" href="/domestic/rating">Click for results</a>"""
status = ''
return htmlify(serie['title'], e+z)


def Rating():
content = ''
for serie_name in dizi_dict:
serie = dizi_dict[serie_name]
character = ''
for c_name in serie['character']:
c = serie['character'][c_name]

character += "<p class='rating-text'> {name} has been rated {radio} points by {usercount} people.<p>".format(name=c['value'], radio=c['rating'], usercount=serie['usercount'])
x = """<p class="rating-text"> {name} has been rated {rating} points by {usercount} people.</p>
{characters}</br>""".format(name=serie['title'], characters= character, rating=serie['rating'], usercount=serie['usercount'])
content += x
return htmlify('Rating', content)




def series_page1(name):
global status
serie = dizi_dict[name]
serie['rating'] += int(request.forms.get(serie['radio']))
serie['usercount'] += 1

for r in request.forms.getall('name'):
serie['character'][r]['rating'] += 1

status = '<p class="thank-text">Thank You</p>'
#print dizi_dict
redirect('/domestic/{}'.format(name))


route('/assignment3/', 'GET', a3_index)
route('/', 'GET', website_index)
route('/assignment3/', 'GET', choose)
route('/assignment3/', 'POST', calistir)
route('/domestic/', 'GET', domestic_page)
route('/domestic/', 'POST', calistir2)
route('/domestic/<name>', 'GET', series_page)
route('/domestic/<name>', 'POST', series_page1)
route('/domestic/rating', 'GET', Rating)
route('/static/<filename>', 'GET', Static)



#####################################################################
### Don't alter the below code.
### It allows this website to be hosted on PythonAnywhere
### OR run on your computer.
#####################################################################

# This line makes bottle give nicer error messages
debug(True)
# This line is necessary for running on PythonAnywhere
application = default_app()
# The below code is necessary for running this bottle app standalone on your computer.
if __name__ == "__main__":
run()
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.