diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000..fb302ac --- /dev/null +++ b/app.yaml @@ -0,0 +1,13 @@ +runtime: python37 + +handlers: + # This configures Google App Engine to serve the files in the app's static + # directory. +- url: /static + static_dir: static + + # This handler routes all requests not caught above to your main app. It is + # required when static routes are defined, but can be omitted (along with + # the entire handlers section) when there are no static files defined. +- url: /.* + script: auto \ No newline at end of file diff --git a/appengine_config.py b/appengine_config.py new file mode 100644 index 0000000..c039151 --- /dev/null +++ b/appengine_config.py @@ -0,0 +1,20 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# [START vendor] +from google.appengine.ext import vendor + +# Add any libraries installed in the "lib" folder. +vendor.add('lib') +# [END vendor] diff --git a/main.py b/main.py index 6463544..7fd158f 100755 --- a/main.py +++ b/main.py @@ -6,16 +6,22 @@ from oauth2client.service_account import ServiceAccountCredentials from flask import Flask, render_template -application = Flask(__name__, static_url_path='/static') +app= Flask(__name__, static_url_path='/static') CURRENT_DIR = os.path.dirname(os.path.realpath(__file__)) -credentials = ServiceAccountCredentials.from_json_keyfile_name( CURRENT_DIR + '/coastal.json', - scopes = ['https://spreadsheets.google.com/feeds', - 'https://www.googleapis.com/auth/drive' ] - ) -@application.route('/') +credentials = ServiceAccountCredentials.from_json_keyfile_name(CURRENT_DIR + '/coastal.json', + scopes=['https://spreadsheets.google.com/feeds', + 'https://www.googleapis.com/auth/drive'] + ) + + +@app.route('/') def index(): + """ + Open the home page. Read the spreadsheet to populate the events and speakers + :return: + """ spreadsheet = gspread.authorize(credentials) calendar = spreadsheet.open('Coastal Calendar') speakers = calendar.worksheet("Speakers") @@ -38,28 +44,28 @@ def index(): for r,row in enumerate( events.get_all_values()): if r == 0: continue - - day = datetime.strptime(row[0],"%m/%d/%Y") - event_details.append( { 'date' :day.strftime( "%a %B %d, %Y" ), - 'describe':row[1], - 'place' :row[2], - 'notes' :row[3] - } ) + + day = datetime.strptime(row[0], "%m/%d/%Y") + event_details.append({'date': day.strftime("%a %B %d, %Y"), + 'describe': row[1], + 'place': row[2], + 'notes': row[3] + }) context = {'speakers':speaker_details, 'events':event_details} return render_template( 'main.html', **context ) -@application.errorhandler(404) +@app.errorhandler(404) def page_not_found(e): """Return a custom 404 error.""" return 'Sorry, Nothing at this URL.', 404 -@application.errorhandler(500) +@app.errorhandler(500) def application_error(e): """Return a custom 500 error.""" return 'Sorry, unexpected error: {}'.format(e), 500 if __name__ == '__main__': - application.run(debug = False, host='0.0.0.0', port=8000) + app.run(debug = False, host='0.0.0.0', port=8000) diff --git a/requirements.txt b/requirements.txt index 62dd252..4430cd7 100755 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ Flask==0.10 gspread==0.3.0 oauth2client==2.0.0.post1 -arrow==0.7.0 \ No newline at end of file +arrow==0.7.0 +gunicorn diff --git a/templates/main.html b/templates/main.html index 81053b7..122b28e 100644 --- a/templates/main.html +++ b/templates/main.html @@ -41,8 +41,8 @@
Meetings are held 7:30PM the third Tuesday of every month at the Larkin House 380 Godwin Ave, Wyckoff, NJ 07481 If you have questions about any meeting please post it on the message board and we will answer you.
-Meetings are held 7:30PM the third Tuesday of every month at the Wyckoff Larkin House 380 Godwin Ave, Wyckoff, NJ 07481 If you have questions about any meeting please post it on the message board and we will answer you.
+