mirror of
				https://gitlab.com/ceda_ei/sky
				synced 2025-11-04 04:20:05 +01:00 
			
		
		
		
	Add server.py with base structure. Update .gitignore.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,3 @@
 | 
			
		||||
config.py
 | 
			
		||||
__pycache__/
 | 
			
		||||
cache.sqlite
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								server.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								server.py
									
									
									
									
									
										Normal 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))
 | 
			
		||||
		Reference in New Issue
	
	Block a user