我成功将我的应用程序上传到Google App Engine,但是当我想要从页面执行操作(GET/POST)
时,除非我手动刷新页面,否则它无效。
这是我凌乱的项目结构:
index.html
文件(由/main
调用)是第一个加载的页面,该文件位于templates
目录中。所有其他文件(html和.js)都位于在名为html
的单独目录中。感觉到这可能是原因,我将这些脚本添加到我的index.html文件中:
<script src="/html/js/registration.js"></script>
<script src="/html/js/profile-page.js"></script>
没有运气。
此外,profile-page.html
和registration.html
文件的顶部是相应的.js
文件。
如果我在注册页面中输入数据,它不会被发布到服务器,但如果我在输入数据之前刷新页面,它就可以工作。与配置文件页面显示我输入的数据。< / p>
** App.yaml:**
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /js/(.*\.js)
mime_type: application/javascript
static_files: js/\1
upload: js/(.*\.js)
- url: /images
static_dir: images
- url: /stylesheets
static_dir: stylesheets
- url: /html
static_dir: html
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
的index.html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="content-type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/html/js/jquery.js"></script>
<link href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script src="/html/js/jquery.mobile.js"></script>
<script src="/html/js/profile-page.js"></script>
<script src="/html/js/team-members-view.js"></script>
<script src="/html/js/view-teams.js"></script>
<script src="/html/js/registration.js"></script>
<script src="/html/js/daily-activities.js"></script>
<script src="/html/js/choose-team.js"></script>
<title></title>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header" data-theme="b">
<h1> Home </h1>
</div>
<div data-role="content">
<img src="/html/images/logo.jpg" width="450" height="300"/>
<ul data-role="listview" data-theme="b" data-inset="true">
<li><a href="/html/registration-page.html" id="home-to-reg-button">Click your to register</a></li>
<li><a href="/html/profile-page.html">View Your Profile</a></li>
</ul>
</div>
<div data-role="footer" data-position="fixed" data-theme="b">
<h3>© </h3>
</div>
</div>
</body>
</html>
MainHandler:
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write(template.render('templates/index.html', {}))
app = webapp2.WSGIApplication([
('/', MainHandler),
('/uploadNewMember', MemberRegistrationHandler),
('/profileView', MemberDetailsHandler)
], debug=True)