Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Created September 30, 2011 16:01
Show Gist options
  • Save heavenshell/1254213 to your computer and use it in GitHub Desktop.
Save heavenshell/1254213 to your computer and use it in GitHub Desktop.
Flask static file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/<arg1>/<arg2>/<arg3>/', strict_slashes=False)
def arg3(arg1, arg2, arg3):
print arg1, arg2, arg3
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
$ tree
.
├── app.py
├── static
│   └── css
│   └── style.css
└── templates
└── index.html
3 directories, 3 files
$ python app.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
foo bar baz
127.0.0.1 - - [01/Oct/2011 01:14:38] "GET /foo/bar/baz/ HTTP/1.1" 200 -
static css style.css
127.0.0.1 - - [01/Oct/2011 01:14:38] "GET /static/css/style.css HTTP/1.1" 200 -
127.0.0.1 - - [01/Oct/2011 01:14:38] "GET /favicon.ico HTTP/1.1" 404 -
body { font-family: sans-serif; background: #eee; }
<!doctype html>
<html>
<head>
<title>Flaskr</title>
<link rel=stylesheet type=text/css href="/static/style.css" />
</head>
<body>
Sample
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment