Skip to content

Commit e284c93

Browse files
author
Logan
committed
Merge pull request googlearchive#3 from proppy/master
simpler skeleton
2 parents d73bbdb + da5e738 commit e284c93

File tree

10 files changed

+45
-68
lines changed

10 files changed

+45
-68
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.pyc
2-
# don't include Flask and depedencies
3-
server/lib/*
4-
# include README so user doesn't have to create this dir
5-
!server/lib/README.txt
2+
# don't include third-party dependencies.
3+
lib/
4+
!lib/README.md
65
.DS_Store

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ See the README file for directions. You'll need python 2.7 and [pip 1.4 or later
1414
2. Clone this repo with
1515

1616
```
17-
git clone <project URL>
17+
git clone https://github.com/GoogleCloudPlatform/appengine-python-flask-skeleton.git
1818
```
19-
3. Install dependencies in the project's server/lib directory - App Engine
20-
can only import libraries from inside your project directory.
19+
3. Install dependencies in the project's lib directory.
20+
Note: App Engine can only import libraries from inside your project directory.
2121

2222
```
23-
cd <project_directory>
24-
pip install -r requirements.txt -t server/lib
23+
cd appengine-python-flask-skeleton
24+
pip install -r requirements.txt -t lib
2525
```
2626
4. Run this project locally from the command line:
2727

2828
```
29-
dev_appserver.py <projectDirectory>
29+
dev_appserver.py .
3030
```
3131

3232
Visit the application [http://localhost:8080](http://localhost:8080)
@@ -43,12 +43,12 @@ To deploy the application:
4343
application](https://developers.google.com/appengine/docs/python/tools/uploadinganapp) with
4444

4545
```
46-
appcfg.py -A <your-project-id> --oauth2 update [projectDirectory]
46+
appcfg.py -A <your-project-id> --oauth2 update .
4747
```
4848
1. Congratulations! Your application is now live at your-app-id.appspot.com
4949

5050
## Next Steps
51-
This skeleton includes TODO markers to help you find basic areas you will want
51+
This skeleton includes `TODO` markers to help you find basic areas you will want
5252
to customize.
5353

5454
### Relational Databases and Datastore
@@ -76,4 +76,4 @@ See [CONTRIB.md](CONTRIB.md)
7676
See [LICENSE](LICENSE)
7777

7878
## Author
79-
Logan Henriquez
79+
Logan Henriquez and Johan Euphrosine

app.yaml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@
66
# TODO: Enter your application id below. If you have signed up
77
# using cloud.google.com/console use the "project id" for your application
88
# id.
9-
application: your-app-or-project-id-here
9+
application: your-application-id-here
1010
version: 1
1111
runtime: python27
1212
api_version: 1
1313
threadsafe: yes
1414

15-
# Handlers tell app engine how to route requests to your application.
15+
# Handlers define how to route requests to your application.
1616
handlers:
1717

18-
# Route requests to static files (and subdirectories) in the listed
19-
# directories.
20-
- url: /static
21-
static_dir: static
22-
23-
# Make robots.txt accessible at the root URL.
24-
- url: /robots.txt
25-
static_files: static/robots.txt
26-
upload: static/robots.txt
18+
# App Engine serves and caches static files contained in the listed directories
19+
# (and subdirectories). Uncomment and set the directory as needed.
20+
#- url: /client
21+
# static_dir: client
2722

2823
# This handler tells app engine how to route requests to a WSGI application.
2924
# The script value is in the format <path.to.module>.<wsgi_application>
@@ -37,10 +32,7 @@ handlers:
3732
# a list of libraries included in the SDK. Third party libs that are *not* part
3833
# of the App Engine SDK don't need to be listed here, instead add them to your
3934
# project directory, either as a git submodule or as a plain subdirectory.
40-
# Note that dependencies must be located in your project directory - packages
41-
# installed in the Python environment are not loaded by the App Engine development
42-
# server or deployment tools.
4335
# TODO: List any other App Engine SDK libs you may need here.
44-
# libraries:
45-
# - name: pycrypto
46-
# version: latest
36+
#libraries:
37+
#- name: jinja2
38+
# version: latest

appengine_config.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import os
1+
"""`appengine_config` gets loaded when starting a new application instance."""
22
import sys
3-
4-
# required to load libraries under server/lib that Flask depends on
5-
app_root_dir = os.path.dirname(__file__)
6-
server_lib_dir = os.path.join(app_root_dir, 'server/lib')
7-
if server_lib_dir not in sys.path:
8-
sys.path.insert(0, server_lib_dir)
3+
import os.path
4+
# add `lib` subdirectory to `sys.path`, so our `main` module can load
5+
# third-party libraries.
6+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))

lib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains third-party dependencies installed with `pip`.

main.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
""" main.py is the top level script.
1+
"""`main` is the top level module for your Flask application."""
22

3-
Return "Hello World" at the root URL.
4-
"""
5-
6-
import os
7-
import sys
8-
9-
# sys.path includes 'server/lib' due to appengine_config.py
3+
# Import the Flask Framework
104
from flask import Flask
11-
from flask import render_template
12-
app = Flask(__name__.split('.')[0])
5+
app = Flask(__name__)
6+
# Note: We don't need to call run() since our application is embedded within
7+
# the App Engine WSGI application server.
138

149

1510
@app.route('/')
16-
@app.route('/<name>')
17-
def hello(name=None):
18-
""" Return hello template at application root URL."""
19-
return render_template('hello.html', name=name)
11+
def hello():
12+
"""Return a friendly HTTP greeting."""
13+
return 'Hello World!'
2014

2115

16+
@app.errorhandler(404)
17+
def page_not_found(e):
18+
"""Return a custom 404 error."""
19+
return 'Sorry, Nothing at this URL.', 404

requirements.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# This requirements file lists all dependecies for this project.
2-
# Run 'pip install -r requirements.txt -t server/lib' to install these dependencies
3-
# in this project's server/lib directory.
1+
# This requirements file lists all third-party dependencies for this project.
2+
#
3+
# Run 'pip install -r requirements.txt -t lib/' to install these dependencies
4+
# in `lib/` subdirectory.
5+
#
6+
# Note: The `lib` directory is added to `sys.path` by `appengine_config.py`.
47
Flask==0.10

server/lib/README.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

static/robots.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

templates/hello.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)