Created
July 14, 2016 17:39
-
-
Save WillEngler/82da034dbfb0b5d00fa79f6a0f770517 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import environ | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from flask_admin import Admin | |
from geoalchemy2 import Geometry | |
from flask_admin.contrib.geoa import ModelView | |
app = Flask(__name__) | |
app.config['SQLALCHEMY_DATABASE_URI'] = \ | |
'postgresql://postgres:password@localhost:5432/node_config' | |
app.config['MAPBOX_ACCESS_TOKEN'] = environ.get("MAPBOX_TOKEN") | |
print(environ.get("MAPBOX_TOKEN")) | |
app.config['MAPBOX_MAP_ID'] = "mapbox.streets" | |
app.secret_key = environ.get("SECRET_KEY") | |
db = SQLAlchemy(app) | |
admin = Admin(app, name='node-config', template_mode='bootstrap3') | |
class Thing(db.Model): | |
id = db.Column(db.Integer, primary_key=True) | |
location = db.Column(Geometry('POINT')) | |
admin.add_view(ModelView(Thing, db.session)) | |
if __name__ == '__main__': | |
db.session.rollback() | |
db.session.execute('DROP TABLE IF EXISTS thing;') | |
db.session.commit() | |
db.create_all() | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment