1

我有一个带有一些阿拉伯数字的网页,其中通过鼠标悬停动作播放音频并且数字发音。它在我的浏览器中本地工作,但在谷歌应用引擎下不起作用。它在谷歌应用引擎下也不能在本地工作,但如果我只运行 html 文件,它就可以工作。这是我的代码的一部分

<script language="javascript" type="text/javascript">

 function playSound(soundfile) {
 document.getElementById("dummy").innerHTML=
 "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
 };
 </script>

<div>

    <table>
        <tr>    
            <td onmouseover="playSound('numbers/1.mp3');">واحِد</td>
            <td onmouseover="playSound('numbers/1st.mp3');">الأَوَّل</td>
            <td onmouseover="playSound('numbers/1st_f.mp3');">الأُولى</td>
            <td onmouseover="playSound('numbers/saturday.mp3');">السَّبْت</td>
        </tr>

    </table>

这是python代码

import os
import webapp2
import jinja2
from google.appengine.ext import db

template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
                               autoescape=True)

class Handler(webapp2.RequestHandler):
    def write(self, *a, **kw):
        self.response.out.write(*a, **kw)
    def render_str(self, template, **params):
        t = jinja_env.get_template(template)
        return t.render(params)
    def render(self, template, **kw):
        self.write(self.render_str(template, **kw))

class MainPage(Handler):
    def get(self):
        self.render('ArabicNumbers.html')

app = webapp2.WSGIApplication([('/', MainPage)], debug=True)

这是 app.yaml

application: arabicbetweenyourhands
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.1"

- name: jinja2
  version: latest

另外,这里是网站的网址。arabicbetweenyourhands.appspot.com。你可以在那里看到完整的源代码。有任何想法吗??谢谢

4

1 回答 1

5

当我访问您的页面时,我得到了http://arabicbetweenyourhands.appspot.com/numbers/4th_f.mp3的 404

您需要将您的“数字”目录作为静态目录添加到您的 app.yaml 并添加适当的 mime 类型,如下所示:

handlers:
- url: /numbers
  static_dir: numbers
  mime_type: audio/mp3
于 2012-06-16T02:54:37.727 回答