Skip to content

Instantly share code, notes, and snippets.

@Shinichi-Nakagawa
Created April 18, 2015 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shinichi-Nakagawa/c5cb15f34a14f67381d3 to your computer and use it in GitHub Desktop.
Save Shinichi-Nakagawa/c5cb15f34a14f67381d3 to your computer and use it in GitHub Desktop.
bottle + Google Mapなアプリ
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Shinichi Nakagawa'
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from tables import Park, Base
from bottle import route, run, template
from configparser import ConfigParser
config = ConfigParser()
config.read("config.ini")
MAP_API_KEY=config["google"]["api_key"]
MAP_CENTER = {
'lat': 37.751526,
'lng': -122.200470,
}
def get_session():
engine = create_engine('sqlite:///ballpark.db', echo=True)
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
return Session()
@route('/')
def index():
session = get_session()
return template(
'map',
map_key=MAP_API_KEY,
sensor='false',
center_lat=MAP_CENTER['lat'],
center_lon=MAP_CENTER['lng'],
parks=list(session.query(Park).all())
)
if __name__ == '__main__':
run(host='localhost', port=8000, debug=True, reloader=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment