Jumat, 23 Juni 2017

web app walkthrough design


web app walkthrough design

hi i'm brett slatkin, asoftware engineer on the google app engine team. app engine enables editors tobuild web applications on google's infrastructure. i'm here today to show you howto quickly build a guest book application using app engine.let's get started. first we'll create a directoryfor my new application and bring it into my editor. then i'll create an "app.yamo"file with my

application configuration. i'll type my application name. version of this application,in this case the first version. version of the apis i'm goingto be using. and the runtime,which is "python." then i declare how my url isgoing to map to my application. in this case, i'm going tohave all urls go to single

python scripts called "main." i'll create mymain python file. i'll type in a very basic,"hello world" application. now i'll go to the terminaland start the development web server. and now that the server isrunning, i can go and view the "hello world" application. now let's do something morecomplicated and build a web application.

to do this we've provided avery basic web application framework called "web app." i'll import the "web app"module and then define a handler, which will handlethe requests from the application. the methods of this classwill handle htp requests. in this case, i just want tohandle a get request, and i'll print out a"hello world" message. text "schema handler" i'll use "wsgiref," which is

python standardweb application container. and i'll define a"wsgiapplication" throughout all url's access to myreally basic handler. and of course, tell phythonto run my main function. now let's view thisin our browser. great. it showed upand it's working. now let's do some templates tomake this page look better. we provide a basiclibrary for doing this. let's create a template fileusing django templates.

to begin with, i'll just havesome html that says, "hello world." i'll import ourtemplate module. and then render the template. and then i can viewthis in my browser. now let's implement a basicui for our web application. i'll go back into my templatefile and start writing my ui and html.so first i'll have a form. in this case, i want to post.

and the form will havea couple of fields. since it's a guest book, let'sstart off with the message i want to have. in this case, it's just textfields with "message." and we'll change the "submit"button to say "shout." and now we can go backand view this in our browser. so let's have our webapplication handle the post request and then dosomething more interesting. i'll modify "myhandler" tohandle post requests, as well

as the "get" requests. now let's hook thisup to the data store. to use the data store, i'llimport the dv module and to find a model class that sayswhat fields will have to store in the data store. in this case, my model classwill be called "shout." and i'll have two fields. first, the message. and then the time themessage was left. now, in the post method, i'lluse the request parameters to

create a new "shout" andput it in the data store. then i'll redirect the userback to the main page. then i can go back to mybrowser and see this is working right now. now we're handling posts andputting posts and putting data in the data store,but we're no retrieving it. so let's create a query to getthe data back out and present it to the user. to do this i'llcreate a "gqlquery."

and then i'll use the resultsof the query to populate my templates. and passes valuesinto the template renderer. then if i go into my template,i can use the results of the query and render themto the user. in this case,i'm using django templates. now i can go back to mybrowser and see this is immediately working. and there are my tworequests from before.

now i can type of fewmore messages. you'll see they are not inany particular order. so i'd like to add a sortorder to my query. new messages go to the top. i'll modify my model to haveanother property, which is"who set the message?" in this case, it's optionalbecause some of the messages were sent withoutan explicit sender. then i'm going to go to mytemplate and add

that new field. it would also be good to havelabels on these input fields. then i need to make sure thatwhen i create my shot i've correctly populatedthe "who" field. i'd also like to render whosent each message. so, i'll go back to mytemplate and add that too. in the case the "who" field isempty, i'll just say it's from anonymous. now let's go back to thebrowser and see what

this looks like. you can see all the messagesare from anonymous because none of them has a sender. let's add a new onewith a sender for me. you'll see my namehas appeared. one last thing i'm going to dois fix the title to point out this is my applicationcalled "shoutout!" for this application,i'll use the app config tool. i'll just type, "appcfigupdate" to deploy my

application and then thenaming application directory. and we're done. now i can access thisapplication on appspot.com. now let's leave a message. that's it. we built anapplication and deployed it. we hope that you checkout google app engine. we look forward tohearing your comments. if you'd like to learn moreabout app engine, please join us at google io, google'sdeveloper event on

may 28th and 29th. thanks for watching.

web app walkthrough design Free Image Patterns for Web Background

Tidak ada komentar:

Posting Komentar