Add server.py with base structure. Update .gitignore.

This commit is contained in:
Ceda EI 2018-12-09 16:42:28 +05:30
parent 1f267591ab
commit c3bd238bdc
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
config.py
__pycache__/
cache.sqlite

26
server.py Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
from flask import Flask
from mapbox import Geocoder
import sqlite3
import config
geocoder = Geocoder(access_token=config.mapbox_key)
app = Flask(__name__)
cache_db = sqlite3.connect("cache.sqlite")
@app.route('/')
def index():
text = ("To get the weather for a location, run curl "
"https://sky.webionite.com/location. \n"
"Source: https://gitlab.com/ceda_ei/sky\n")
return text
def main(location, geocoder, cache_db):
return
app.add_url_rule('/<location>', 'location', lambda location:
main(location, geocoder, cache_db))