I am watching one tutorial to get a basic web app saying "hello, world" But for some reason I don't understand, I am getting this "The localhost page isn't working localhost is currently unable to handle this request."
This is what I did. 1. I installed Google App Engine SDK for python. 2. I created two files like this:
main.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
I didnt write these. These were given in google app engine website.
and I tried two different methods to run it.
I used this command: dev_appserver.py . and this is what I get:
INFO 2016-04-02 04:28:02,071 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO 2016-04-02 04:28:02,949 sdk_update_checker.py:257] The SDK is up to date.
INFO 2016-04-02 04:28:02,982 api_server.py:205] Starting API server at: http://localhost:50345
INFO 2016-04-02 04:28:02,988 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO 2016-04-02 04:28:02,989 admin_server.py:116] Starting admin server at: http://localhost:8000
and when I enter " http://localhost:8000 " on chrome, I get this error msg: "The localhost page isn't working localhost is currently unable to handle this request."
and this is the error msg I get on terminal
ERROR 2016-04-02 04:43:47,109 wsgi.py:263]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
ImportError: No module named helloworld
INFO 2016-04-02 04:43:47,114 module.py:787] default: "GET / HTTP/1.1" 500 -
ERROR 2016-04-02 04:43:47,602 wsgi.py:263]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
ImportError: No module named helloworld
INFO 2016-04-02 04:43:47,606 module.py:787] default: "GET / HTTP/1.1" 500 -
What is it that I am doing wrong? Thank you.
The issue you have is that you've named your module main.py
, but told the GAE server to look for a module named helloworld
. That module doesn't exist, so the site can't be loaded.
Either rename your main.py
file to helloworld.py
, or change app.yaml
to point to main.app
instead of helloworld.app
.
webapp2 doesnt have a good introduction. if you're new to web frameworks i would adivse you to start through this one.
https://github.com/iogf/untwisted
It is an event-driven library that has a set of plugins implemented and one of the is a micro web framework whose design is similar to flask but much faster.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.