forked from pyeve/eve-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
41 lines (31 loc) · 1.08 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
"""
Eve Demo
~~~~~~~~
A demostration of a simple API powered by Eve REST API.
The live demo is available at eve-demo.herokuapp.com. Please keep in mind
that the it is running on Heroku's free tier using a free MongoHQ
sandbox, which means that the first request to the service will probably
be slow. The database gets a reset every now and then.
:copyright: (c) 2015 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import os
from eve import Eve
# Heroku support: bind to PORT if defined, otherwise default to 5000.
if 'PORT' in os.environ:
port = int(os.environ.get('PORT'))
# use '0.0.0.0' to ensure your REST API is reachable from all your
# network (and not only your computer).
host = '0.0.0.0'
else:
port = 5000
host = '127.0.0.1'
app = Eve()
@app.after_request
def after_request(response):
response.headers.add('X-Ahmed', 'Je Suis Ahmed.')
response.headers.add('X-Charlie', 'Je Suis Charlie.')
return response
if __name__ == '__main__':
app.run(host=host, port=port)