瀏覽代碼

Remove hard-coded file routes.

Add:
        app.py
                -Remove hard-coded routes for files in the application's "root"
                (`static/`) directory; redefined Flask's `static_url_path`
                accordingly. Files can now be directly accessed by URL.

        bitshift/assets.py
                -Remove the `static/` prepended to all resource paths.
tags/v1.0^2
Severyn Kozak 10 年之前
父節點
當前提交
cd1c9a2ec1
共有 4 個檔案被更改,包括 3 行新增10 行删除
  1. +1
    -7
      app.py
  2. +2
    -2
      bitshift/assets.py
  3. +0
    -0
      static/favicon.ico
  4. +0
    -1
      templates/layout.html

+ 1
- 7
app.py 查看文件

@@ -12,7 +12,7 @@ from bitshift.database import Database
from bitshift.languages import LANGS
from bitshift.query import parse_query, QueryParseException

app = Flask(__name__)
app = Flask(__name__, static_folder="static", static_url_path="")
app.config.from_object("bitshift.config")
app.jinja_env.globals.update(year=datetime.datetime.now().year)

@@ -56,11 +56,5 @@ def about():
def developers():
return render_template("developers.html")

@app.route("/robots.txt")
@app.route("/sitemap.xml")
@app.route("/favicon.ico")
def static_from_root():
return flask.send_from_directory(app.static_folder, request.path[1:])

if __name__ == "__main__":
app.run(debug=True)

+ 2
- 2
bitshift/assets.py 查看文件

@@ -5,8 +5,8 @@
from flask import Markup

ASSET_HTML_TEMPLATES = {
'css': "<link rel='stylesheet' type='text/css' href='/static/css/%s'>",
'js': "<script src='/static/js/%s'></script>"
'css': "<link rel='stylesheet' type='text/css' href='/css/%s'>",
'js': "<script src='/js/%s'></script>"
}

def tag(filename):


static/img/favicon.ico → static/favicon.ico 查看文件


+ 0
- 1
templates/layout.html 查看文件

@@ -16,7 +16,6 @@
<meta name="keywords" content="source code language search engine"/>
<meta name="author" content="Benjamin Attal Ben Kurtovic Severyn Kozak"/>

<link rel="shortcut icon" href="static/img/favicon.ico">
{{ assets.tag("main.css") }}
{{ assets.tag("main.js") }}



Loading…
取消
儲存