What can I use to pass the file argument in the script from the html code to cherrypy function
<p>So what can I do to pass the argument to the function.</p>

<pre><code>import os, random, string
import cherrypy


class StringGenerator(object):

    @cherrypy.expose        
    def index(self):        
      return """&lt;!DOCTYPE html&gt;

&lt;html lang="en"&gt;

  &lt;head&gt;

    &lt;meta charset="utf-8"&gt;

    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;

    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;

    &lt;!-- The above 3 meta tags *must* come first in the head; any other head 

content must come *after* these tags --&gt;

    &lt;title&gt;Bootstrap 101 Template&lt;/title&gt;




    &lt;!-- Bootstrap --&gt;

    &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
rel="stylesheet"&gt;



  &lt;/head&gt;

  &lt;body&gt;

   &lt;div class="jumbotron"&gt;


    &lt;p &gt;&lt;h4 class='text-success'  style='margin-left:30%;'&gt;This is the twitter 
word select &lt;/h1&gt;&lt;/p&gt;


     &lt;form class="form-inline" action="generate/" style='margin-left:20%;' 
enctype= "multipart/form-data"&gt;




  &lt;div class="form-group" &gt;


    &lt;label for="exampleInputName2"&gt;Enter the file name&lt;/label&gt;


    &lt;input type="file" class="form-control" name="file1" id="file" placeholder=" enter the file "&gt;


  &lt;/div&gt;&lt;div class="form-group" &gt;


    &lt;label for="exampleInputName2"&gt;Enter the prefrence&lt;/label&gt;


    &lt;input type="text" class="form-control" name="length" id="exampleInputName2" placeholder=" enter the preference "&gt;


  &lt;/div&gt;


  &lt;button type="submit" class="btn btn-primary"&gt;Result&lt;/button&gt;


&lt;/form&gt;



  &lt;/div&gt; &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;


    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;


    &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt;


    &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;

  &lt;/body&gt;


&lt;/html&gt;"""


    @cherrypy.expose            
    def generate(self, length,file1):            
        some_string = "harsh"+length        
        cherrypy.session['mystring'] = some_string        
        fp = open(file1)      
        return fb

    @cherrypy.expose
    def display(self):    
        return cherrypy.session['mystring']

if __name__ == '__main__':
    conf = {
        '/': {
            'tools.sessions.on': True,
            'tools.staticdir.root': os.path.abspath(os.getcwd())
        },


        '/static': {

            'tools.staticdir.on': True,
            'tools.staticdir.dir': './public'
        }
    }
    cherrypy.quickstart(StringGenerator(), '/', conf)
</code></pre>

<p>Take a look into the file <a href="https://github.com/cherrypy/cherrypy/blob/master/cherrypy/tutorial/tut09_files.py" rel="nofollow">cherrypy files tutorial</a>, but to provide you with a concrete answer, your <code>generate</code> method has to use the <code>file</code> attribute of the <code>file1</code> parameter.</p>

<p>For example, this method would work:</p>

<pre><code>@cherrypy.expose            
def generate(self, length, file1):            
    some_string = "harsh" + length        
    cherrypy.session['mystring'] = some_string        
    file_content = file1.file.read()
    return file_content
</code></pre>

<p>You can also operate on the <code>file</code> attribute to get more information, it's an instance of a python <a href="https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryFile" rel="nofollow">TemporaryFile</a>.</p>

python cherrypy