2011-03-31 47 views
1

首先我是新來的,所以如果我犯了什麼錯誤,請將它們指出來。如何將.swf文件嵌入到我的Google App Engine應用程序中?

我正在Python應用引擎項目上工作,我想能夠以.swf格式上傳和玩遊戲。我無法讓應用程序引擎以.swf結尾發送(傳送,呈現,顯示......不知道正確的詞是什麼)文件。

我在做什麼錯?

我試過在我的對象標記中嵌入一張圖片,以確保我的html和Django模板不是造成問題的原因,並且工作正常。

這是我的app.yaml文件

application: flashstealer 
version: 1 
runtime: python 
api_version: 1 

handlers: 
- url: /stylesheets 
    static_dir: stylesheets 

- url: /images 
    static_dir: images 

- url: /flashgames 
    static_dir: flashgames 

- url: .* 
    script: main.py 

...我main.py

import wsgiref.handlers 
from google.appengine.ext import db 
from google.appengine.ext import webapp 
from google.appengine.ext.webapp import template 

class Game(db.Model): 
    name = db.StringProperty() 
    description = db.StringProperty() 
    tags = db.StringListProperty() 
    playcount = db.IntegerProperty() 
    location = db.StringProperty() 
    originallocation = db.StringProperty() 

class MyHandler(webapp.RequestHandler): 
    def get(self): 
     games = db.GqlQuery('SELECT * FROM Game LIMIT 20') 
     self.response.out.write(template.render('main.html',{'games': games})) 
    def post(self): 
     game = Game(
      name = self.request.get('name'), 
      description = self.request.get('description'), 
      #tags = self.request.get('tags'), 
      #playcount = self.request.get('playcount'), 
      location = self.request.get('location'), 
      originallocation = self.request.get('originallocation')) 
     game.put() 
     self.redirect("/") 
def main(): 
    app = webapp.WSGIApplication([(r'.*', MyHandler)],debug=True) 
    wsgiref.handlers.CGIHandler().run(app) 

if __name__ == '__main__': 
    main() 

...和我的main.html中

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>Emporium by Free Css Templates</title> 
<meta name="keywords" content="" /> 
<meta name="description" content="" /> 
<link href="stylesheets/default.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<div id="wrapper"> 
<!-- start header --> 
<div id="logo"> 
    <h1><a href="#">The Arcade</a></h1> 
    <h2> &raquo;&nbsp;&nbsp;&nbsp;but just a fondation for now</h2> 
</div> 
<div id="header"> 
    <div id="menu"> 
     <ul> 
      <li class="current_page_item"><a href="#">Homepage</a></li> 
      <li><a href="#">Blogs</a></li> 
      <li><a href="#">Photos</a></li> 
      <li><a href="#">About</a></li> 
      <li class="last"><a href="#">Contact</a></li> 
     </ul> 
    </div> 
</div> 
<!-- end header --> 
</div> 
<!-- start page --> 
<div id="page"> 
    <!-- start content --> 
    <div id="content"> 
     {% for game in games %} 
     <div class="post"> 
      <h1 class="title">{{game.name}}</h1> 
      <div class="entry"> 
       <embed src="{{game.location}}" width="100%" height="400"> 
       <p>{{game.description}}</p> 
      </div> 
      <div class="meta"> 
       <p class="links"> 
        <a href="#" class="more">Read full article</a> 
         <b>|</b> 
        <a href="#" class="comments">Play Count ({{game.playcount}})</a> 
       </p> 
      </div> 
     </div> 
     {% endfor %} 
     <div class="post"> 
      <h2 class="title">Submit Games Here</h2> 
      <div class="entry"> 
      <form action="" method="post"> 
      <fieldset> 
      Name:<p><input type="stringfield" name="name" ></p> 
      Descrition:<p><input type="stringfield" name="description"></p> 
      Original Location:<p><input type="stringfield" name="originallocation"></p> 
      Playcount:<p><input type="stringfield" name="playcount" ></p> 
      Location:<p><input type="stringfield" name="location"></p> 
      Tags:<p><input type="stringfield" name="tags"></p> 
      <p><input type="submit" value="post"></p> 
      </fieldset> 
      </form> 
      </div> 
      <div class="meta"> 
       <p class="links"> 
           <a href="#" class="more">Read full article</a> 
           <b>|</b> 
           <a href="#" class="comments">Comments (32)</a> 
          </p> 
      </div> 
     </div> 
    </div> 
    <!-- end content --> 
    <!-- start sidebar --> 
    <div id="sidebar"> 
     <ul> 
      <li id="search"> 
       <h2>Search</h2> 
       <form method="post" action=""> 
        <fieldset> 
        <input type="text" id="message" name="message" value="" /> 
        <input type="submit" id="x" value="Search" /> 
        </fieldset> 
       </form> 
      </li> 
      <li> 
       <h2>To Do</h2> 
       <ul> 
        <li><a href="#">make a list of games in db</a></li> 

       </ul> 
      </li> 
     </ul> 
    </div> 
    <!-- end sidebar --> 
    <div style="clear: both;">&nbsp;</div> 
</div> 
<!-- end page --> 
<!-- start footer --> 
<div id="footer"> 
    <p id="legal"></p> 
</div> 
<!-- end footer --> 
</body> 
</html> 

因爲我'新我不能直接張貼照片

the way the browser shows it

這是它顯示的方式,當我查看渲染(又管它叫什麼)HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>Emporium by Free Css Templates</title> 
<meta name="keywords" content="" /> 
<meta name="description" content="" /> 
<link href="stylesheets/default.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<div id="wrapper"> 
<!-- start header --> 
<div id="logo"> 
    <h1><a href="#">The Arcade</a></h1> 
    <h2> &raquo;&nbsp;&nbsp;&nbsp;but just a fondation for now</h2> 
</div> 
<div id="header"> 
    <div id="menu"> 
     <ul> 
      <li class="current_page_item"><a href="#">Homepage</a></li> 
      <li><a href="#">Blogs</a></li> 
      <li><a href="#">Photos</a></li> 
      <li><a href="#">About</a></li> 
      <li class="last"><a href="#">Contact</a></li> 
     </ul> 
    </div> 
</div> 
<!-- end header --> 
</div> 
<!-- start page --> 
<div id="page"> 
    <!-- start content --> 
    <div id="content"> 

     <div class="post"> 
      <h1 class="title">Test with .swf</h1> 
      <div class="entry"> 
       <embed src="/flashgames/aow2.swf"> 
       <p>This is were the problem starts because it leaves a spot where the game should be but there's no game.</p> 
      </div> 
      <div class="meta"> 
       <p class="links"> 
        <a href="#" class="more">Read full article</a> 
         <b>|</b> 
        <a href="#" class="comments">Play Count (None)</a> 
       </p> 
      </div> 
     </div> 

     <div class="post"> 
      <h1 class="title">Test with .img</h1> 
      <div class="entry"> 
       <object width="100%" height="400"> 
       <embed src="/images/img01.jpg"> 
       </object> 
       <p>This is proof that it's not my html and template that's causing the problem</p> 
      </div> 
      <div class="meta"> 
       <p class="links"> 
        <a href="#" class="more">Read full article</a> 
         <b>|</b> 
        <a href="#" class="comments">Play Count (None)</a> 
       </p> 
      </div> 
     </div> 

     <div class="post"> 
      <h2 class="title">Submit Games Here</h2> 
      <div class="entry"> 
      <form action="" method="post"> 
      <fieldset> 
      Name:<p><input type="stringfield" name="name" ></p> 
      Descrition:<p><input type="stringfield" name="description"></p> 
      Original Location:<p><input type="stringfield" name="originallocation"></p> 
      Playcount:<p><input type="stringfield" name="playcount" ></p> 
      Location:<p><input type="stringfield" name="location"></p> 
      Tags:<p><input type="stringfield" name="tags"></p> 
      <p><input type="submit" value="post"></p> 
      </fieldset> 
      </form> 
      </div> 
      <div class="meta"> 
       <p class="links"><a href="#" class="more">Read full article</a> <b>|</b> <a href="#" class="comments">Comments (32)</a></p> 
      </div> 
     </div> 
    </div> 
    <!-- end content --> 
    <!-- start sidebar --> 
    <div id="sidebar"> 
     <ul> 
      <li id="search"> 
       <h2>Search</h2> 
       <form method="post" action=""> 
        <fieldset> 
        <input type="text" id="message" name="message" value="" /> 
        <input type="submit" id="x" value="Search" /> 
        </fieldset> 
       </form> 
      </li> 
      <li> 
       <h2>To Do</h2> 
       <ul> 
        <li><a href="#">make a list of games in db</a></li> 

       </ul> 
      </li> 
     </ul> 
    </div> 
    <!-- end sidebar --> 
    <div style="clear: both;">&nbsp;</div> 
</div> 
<!-- end page --> 
<!-- start footer --> 
<div id="footer"> 
    <p id="legal">(c) 2008. All Rights Reserved. <a href="http://www.freecsstemplates.org/">Bestfriends</a> designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p> 
</div> 
<!-- end footer --> 
</body> 
</html> 

這些都是我的根文件夾及其內容

  • 圖像0​​
    • img01.jpg
    • img02.jpg
    • img03.jpg
    • spacer.gif的
  • flashgames
    • aow2.swf
  • 樣式表
    • default.css

回答

2

釷是不是看起來像嵌入一個Flash應用程序的標準方式 - 而且這不是一個App Engine問題。你已經有了一個只有維度的對象標籤,並且只有一個URL,裏面只有一個嵌入標籤。你有沒有嘗試過使用一些標準的嵌入標記來做到這一點? Flash環境應該提供一種簡單的方式來導出嵌入在HTML頁面中的應用程序。您是否嘗試過使用磁盤上的簡單靜態HTML文件進行調試,以便更輕鬆地進行調試並使App Engine脫離等式?

+0

行,刪除標籤,但仍然有同樣的問題,你可以幫助我嗎? PLZ。 – 2011-03-31 15:29:21

+0

@Jonathan刪除對象標記不是我所建議的。您是否嘗試過我的任何建議,例如使用Flash來生成包含您的應用的靜態HTML文件? – 2011-03-31 22:52:16

相關問題