Creating tweets from users

Before we start writing our web page, we need to create a route to create tweets. This can be done as follows:

    from flask import render_template 
 
    @app.route('/addtweets') 
    def addtweetjs(): 
     return render_template('addtweets.html') 

Now that, we have created the route, let's create another form in addtweets.html, which will ask the user for the required information related to tweets, and help them submit the information:

    <html> 
     <head> 
      <title>Twitter Application</title> 
     </head> 
    <body> 
    <form > 
     <div class="navbar"> 
       <div class="navbar-inner"> 
           <a class="brand" href="#">Tweet App Demo</a> 
       </div> 
      </div> 
  
<div id="main" class="container"> <table class="table table-striped"> Username: <input placeholder="Username" type="username">
</input> </div> <div> body: <textarea placeholder="Content of tweet" type="text">
</textarea> </div> <div> </div> <button type="submit">Add Tweet</button> </table> </form> <script src="http://cdnjs.cloudflare.com/ajax/libs/
jquery/1.8.3/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/
knockout/2.2.0/knockout-min.js"></script> <link href="http://netdna.bootstrapcdn.com/twitter-
bootstrap/2.3.2/css/bootstrap-combined.min.css"
rel="stylesheet"> <!-- <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-
1.9.0.js"></script> --> <script src="http://netdna.bootstrapcdn.com/twitter-
bootstrap/2.3.2/js/bootstrap.min.js"></script> </body> </html>

Note that currently, this form doesn't have data binding to communicate with the RESTful services.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.172.38