Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google app engine #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions appengine_config.py
Original file line number Diff line number Diff line change
@@ -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]
38 changes: 22 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
Flask==0.10
gspread==0.3.0
oauth2client==2.0.0.post1
arrow==0.7.0
arrow==0.7.0
gunicorn
12 changes: 4 additions & 8 deletions templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ <h2>Coastal Flyrodders</h2>
<div class="bodycont">
<div class="wrapper" id="meetings">
<h2>Meetings</h2>
<p>Meetings are held 7:30PM the third Tuesday of every month at the Larkin House <a href="https://maps.google.com/maps?q=380+Godwin+Ave,+Wyckoff,+NJ+07481&hnear=380+Godwin+Ave,+Wyckoff,+New+Jersey+07481&gl=us&t=m&z=16">380 Godwin Ave, Wyckoff, NJ 07481 </a> If you have questions about any meeting please post it on the message board and we will answer you.</p>
<h2 class="small">2016 Program Schedule</h2>
<p>Meetings are held 7:30PM the third Tuesday of every month at the Wyckoff Larkin House <a href="https://www.google.com/maps/place/380+Godwin+Ave,+Wyckoff,+NJ+07481/@41.0178219,-74.1686409,17z/data=!3m1!4b1!4m5!3m4!1s0x89c2e3aa0ba94b81:0x6d4f1f4cf25a238c!8m2!3d41.0178219!4d-74.1664522"> 380 Godwin Ave, Wyckoff, NJ 07481 </a> If you have questions about any meeting please post it on the message board and we will answer you.</p>
<h2 class="small">2017 Program Schedule</h2>
</div>
<!-- Start: Program Schedule -->
<!-- January -->
Expand All @@ -64,7 +64,7 @@ <h2 class="small">2016 Program Schedule</h2>
<br/>
<!-- Start: Events -->
<div class="events wrapper" id="events">
<h2>2016 Events</h2>
<h2>Events for the year</h2>

<table width="960" border="0" cellspacing="0" cellpadding="0" class="eventstbl">
<tr>
Expand All @@ -89,7 +89,7 @@ <h2>2016 Events</h2>
<div class="membership" id="membership">
<div class="wrapper">
<h2>Membership</h2>
<a href="Coastal Flyrodders Membership Application.pdf" class="downloadlink">click here to download</a>
<a href="{{url_for('static',filename='Coastal Flyrodders Membership Application.pdf')}}" class="downloadlink">click here to download</a>
<p>Membership is $50.00 per year. You can mail a check to Coastal Flyrodders P.O Box 1402, Morristown, NJ 07962 or use simply use Paypal. You also need to sign the Membership Application. </p>
<div class="paymentoptions">
<div class="inner">
Expand All @@ -100,10 +100,6 @@ <h3>Payment options :</h3>
<input type="hidden" name="hosted_button_id" value="898J9LF9DJ2Y4">
<input type="image" src="{{url_for('static',filename='css/images/icon-paypal.png')}}" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>
<a href="#"><img src="{{url_for('static',filename='css/images/icon-mastercard.png')}}" alt="MasterCard" title="MasterCard" /></a>
<a href="#"><img src="{{url_for('static',filename='css/images/icon-visa.png')}}" alt="Visa" title="Visa" /></a>
<a href="#"><img src="{{url_for('static',filename='css/images/icon-american-express.png')}}" alt="American Express" title="American Express" /></a>
<a href="#"><img src="{{url_for('static',filename='css/images/icon-discover.png')}}" alt="Discover" title="Discover" /></a>
</div>
</div>
</div>
Expand Down