Skip to content

Commit

Permalink
Load defaults from example config
Browse files Browse the repository at this point in the history
This makes some options non-optional -- allowing for a smaller config file.
This also removes the X-Sendfile example, bucause the proxy server should
handle static files directly and the option is not at all specific to this
particular application (and general Flask options aren't documented).
  • Loading branch information
ShadowNinja committed Jan 24, 2016
1 parent ebe788a commit a431911
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -75,8 +75,8 @@ Setting up the server
# # OR:
# pip install uwsgi

4. Configure the server by changing options in config.py, which is a Flask
configuration file.
4. Configure the server by adding options to `config.py`.
See `config-example.py` for defaults.

5. Start the server:

Expand Down
10 changes: 3 additions & 7 deletions config-example.py
@@ -1,16 +1,12 @@

# Enables detailed tracebacks and an interactive Python console on errors.
# Never use in production!
#DEBUG = True
DEBUG = False

# Address for development server to listen on
#HOST = "127.0.0.1"
HOST = "127.0.0.1"
# Port for development server to listen on
#PORT = 5000

# Makes the server more performant at sending static files when the
# server is being proxied by a server that supports X-Sendfile.
#USE_X_SENDFILE = True
PORT = 5000

# File to store the JSON server list data in.
FILENAME = "list.json"
Expand Down
6 changes: 5 additions & 1 deletion server.py
Expand Up @@ -10,7 +10,11 @@
sched.start()

app = Flask(__name__, static_url_path = "")
app.config.from_pyfile("config.py")

# Load configuration
app.config.from_pyfile("config-example.py") # Use example for defaults
if os.path.isfile(os.path.join(app.root_path, "config.py")):
app.config.from_pyfile("config.py")


@app.route("/")
Expand Down

0 comments on commit a431911

Please sign in to comment.