Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:33:10+00:00 2026-05-31T13:33:10+00:00

I am trying to create create a kind of webserver withy python and cherrypy.

  • 0

I am trying to create create a kind of webserver withy python and cherrypy.

I wish to put the htmls into separate files and embedd them into my python script. The code i used to do that is.

    @cherrypy.expose
def welcome(self, loginAttempt = None):
    """ Prompt the user with a login form. The form will be submitted to /signin
        as a POST request, with arguments "username", "password" and "signin"
        Dispaly a login error above the form if there has been one attempted login already.
    """
    #Debugging Process Check
    print "welcome method called with loggedIn = %s" % (loginAttempt)

    if loginAttempt == '1':
       """ If the user has attempted to login once, return the original login page
       with a error message"""
       page = get_file("loginPageE.html") 
       return page

    else:    
        page = """
               <form action='/signin' method='post'>
               Username:  <input type='text' name='username' /> <br />
               Password:  <input type='password' name='password' />
                 <input type='submit' name='signin' value='Sign In'/>
               </form>
        """          
        return page

where loginPageE.html is

<html>
<head>
<title>Failed Login Page</title>
</head>

<body>

<!-- header-wrap -->
<div id="header-wrap">
    <header>

        <hgroup>
            <h1><a href="loginPageE.html">Acebook</a></h1>
            <h3>Not Just Another Social Networking Site</h3>
        </hgroup>


        <ul>
            <form action='/signin' method='post'>
                Username:  <input type='text' name='username' />
                Password:  <input type='password' name='password' />
                           <input type='submit' name='signin' value='Sign In'/>
            </form>
        </ul>


    </header>
</div>

</body>
</html>

However I keep on getting an error message that reads

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/cherrypy/_cprequest.py", line 606, in respond
    cherrypy.response.body = self.handler()
  File "/usr/lib/pymodules/python2.7/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "proj1base.py", line 74, in welcome
    page = get_file("loginPageE.html")
NameError: global name 'get_file' is not defined

I was wondering if anyone could please help?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:33:11+00:00Added an answer on May 31, 2026 at 1:33 pm

    Well, from the error, evidently python doesn’t know what the get_file() function is. Are you sure that at that point of time where you invoke this function inside the welcome() function, get_file() has been defined?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a kind of non-blocking class in python, but I'm not
At the moment I'm trying to create a kind of model in vb.net which
I'm trying to create a generic build template for my Makefiles, kind of like
I'm trying to create some kind of callback for a class template. The code
I am trying to create a simple regex kind of thing for my own
I'm trying to create some kind of grid layout with css: Having a content
I'm trying to create a kind of master/detail UI using an MVP pattern. I
I`m trying to create a message which uses some kind of pluralization. The message
I'm trying to create a website for myself and just ran into this issue:
I'm trying to create this kind of system: a user writes a mail with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.