Monday, 18 April 2016

Create Logon Screen - Python 3 Web Development

Create Logon Screen - Python 3 Web Development  

 Our first task is to create a small applicati on that does litt le more than present the user with a logon screen. It will be the starti ng point of our tasklist applicati on and many others as well. The code for this example as well as most other examples in this book is available from the Packt website. If you have not downloaded it yet, this might be a good ti me to do so. Enter the following pieces of code and save it in a fi le called logonapp.py  in the same directory as the other fi les distributed with this chapter (Chapter 3 in the sample code): Chapter3/logonapp.py

import cherrypy 
import logon 
class Root(object): logon = logon.Logon(path="/logon",                       
authenticated="/",                       
not_authenticated="/goaway")  @cherrypy.expose def index(self):
 username=logon.checkauth('/logon')  
return '''       
<html><body>        
<p>Hello user <b>%s</b></p>        
</body>
</html>'''%username  @cherrypy.expose def goaway(self):  return '''   
 <html> 
 <body>
<h1>Not authenticated, please go away.</h1>      
</body>
</html>''' @cherrypy.expose def somepage(self): 
 username=logon.checkauth('/logon',returntopage=True) 
 return '''<html>       <body><h1>This is some page.</h1>       </body>       </html>'''  
if __name__ == "__main__": 
import os.path current_dir = os.path.dirname(os.path.abspath(__file__))
 cherrypy.quickstart(Root(),config={  '/': {'tools.sessions.on': True }  }  )

If you now run logonapp.py, a very simple application is available on port 8080. It presents the user with a logon screen when the top level page http://localhost:8080/ is accessed.

If a correct username/password combinati on is entered, a welcome message is shown. If an unknown username or wrong password is entered, the user is redirected to http://localhost:8080/goaway. 
The  somepage() method (highlighted) returns a page with (presumably) some useful content. If the user is not yet authenti cated, the logon screen is shown and upon entering the correct credenti als, the user is directed back to http://localhost:8080/somepage. 

Python 3 Web Development Beginner’s Guide

Python 3 Web Development Beginner’s Guide 

Specifi cally, we will look at: 
 How to design a tasklist applicati on 
 How to implement a logon screen 
 What a session is and how this allows us to work with diff erent users at the same ti me 
 How to interact with the server and add or delete tasks 
 How to make entering dates att racti ve and simple with jQuery UI's datapicker widget 
 How to style butt on elements and provide toolti ps and inline labels to input elements

  Designing an Application

should start with a clear idea of what is expected. Not only to determine what is technically required, but almost as important, to defi ne clear boundaries so that we don't lose ti me on things that are just nice to have. Nice to have features are something to be added if there is ti me left  in the project. 

Learn About HTML Colors

Color Values 

Colors are defined using a hexadecimal notation for the combination of
 red, green, and blue color values (RGB).
The lowest value that can be given to one light source is 0 (hex #00). The highest value is 255 (hex #FF). This table shows the result of combining red, green, and blue:
Color Color HEX Color RGB  #000000  rgb(0,0,0)    #FF0000  rgb(255,0,0)     #00FF00 rgb(0,255,0)    #0000FF  rgb(0,0,255)     #FFFF00  rgb(255,255,0)    #00FFFF  rgb(0,255,255)     #FF00FF  rgb(255,0,255)     #C0C0C0 rgb(192,192,192)    #FFFFFF  rgb(255,255,255)
Color Names A collection of color names is supported by most browsers. To view a table of color names that are supported by most browsers visit this web page:
http://profdevtrain.austincc.edu/html/color_names.htm
Note: Only 16 color names are supported by the W3C HTML 4.0 standard (aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow). For all other colors you should use the Color HEX value. 
Color Color HEX Color Name  #F0F8FF AliceBlue   #FAEBD7  AntiqueWhite     #7FFFD4  Aquamarine     #000000  Black     #0000FF Blue     #8A2BE2  BlueViolet     #A52A2A  Brown
Web Safe Colors A few years ago, when most computers supported only 256 different colors, a list of 216 Web Safe Colors was suggested as a Web standard. The reason for this was that the Microsoft and Mac operating system used 40 different "reserved" fixed system colors (about 20 each). This 216 cross platform web safe color palette was originally created to ensure that all computers would display all colors correctly when running a 256 color palette. To view the 216 Cross Platform Colors visit this web page: http://profdevtrain.austincc.edu/html/216.html  
16 Million Different Colors The combination of Red, Green and Blue values from 0 to 255 gives a total of more than 16 million different colors to play with (256 x 256 x 256). Most modern monitors are capable of displaying at least 16,384 different colors. To assist you in using color schemes, check out http://wellstyled.com/tools/colorscheme2/index-en.html. This site lets you test different color schemes for page backgrounds, text and links.

What Are Basic Html Tags?

Basic HTML Tags 

The most important tags in HTML are tags that define headings, paragraphs and line breaks.
Basic HTML Tags Tag Description <html> Defines an HTML document  <body> Defines the document's body <h1> to <h6> Defines header 1 to header 6 <p> Defines a paragraph  <br> Inserts a single line break  <hr> Defines a horizontal rule <!--> Defines a comment   Headings Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading while <h6> defines the smallest.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6> This is a heading</h6>
HTML automatically adds an extra blank line before and after a heading. A useful heading attribute is align.
<h5 align="left">I can align headings </h5>
<h5 align="center">This is a centered heading </h5>
<h5 align="right">This is a heading aligned to the right </h5> 

Most Trending

2016. Powered by Blogger.

Contact us

Name

Email *

Message *