i started teaching myself the basics of web development with python in Google App Engine and webapp2 web frame.
Basically, i would like to create a homepage where i'll post all the links to different projects. each link will direct to a new url where the relevant py file will run.
for now, all i want is to have one link that direct to a Hello World page. that's it. and for the life of me i can't understand how to write the handler for this event (do i even need a hadler?). can someone please tell me what i'm doing wrong?
my files structure is:
+Main Directory (Folder)
- app.yaml
- index.py
+helloworld (Folder)
__init__.py
helloworld.py
app.yaml file:
application: untitam
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
script: index.app
- url: /helloworld.*
script: helloworld.app
- url: /.*
script: index.app
libraries:
- name: webapp2
version: latest
the index.py:
import webapp2
menu=""" <nav>
<ul>
<li> <a href="/helloworld">Hello World</a></li>
</ul>
</nav>
"""
class HomePage (webapp2.RequestHandler):
def get(self):
self.response.out.write(menu)
class HelloHandler(webapp2.RequestHandler):
def get(self):
pass
app = webapp2.WSGIApplication([('/', HomePage),
('/helloworld', HelloHandler)], debug=True)
and the helloworld.py:
import webapp2
class HelloWorld(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
application = webapp2.WSGIApplication([('/helloworld', HelloWorld),], debug=True)
when i press the Hello World link i do get refer to localhost:8080/helloworld but i see a blank page. the log says: ImportError: No module named app
what should i write in the index.py for the helloworld to run after the user press the link. notice that that index.py and helloworld.py are not in the same folder. each project will have its own folder since later i'll use html/css templates and some javascripts.
thanks in advance