add: gitignore
This commit is contained in:
parent
cce24c469a
commit
8402acd68c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
__pycache__
|
Binary file not shown.
|
@ -1,12 +1,11 @@
|
|||
from datetime import datetime
|
||||
from functools import cache
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
import json
|
||||
import urllib.request
|
||||
import os
|
||||
from weather import weather_handler
|
||||
|
||||
|
||||
def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
|
||||
server_address = ("", 8000)
|
||||
server_address = ("", int(os.getenv("PORT", "8000")))
|
||||
httpd = server_class(server_address, WeatherHandler)
|
||||
httpd.serve_forever()
|
||||
|
||||
|
@ -27,19 +26,3 @@ class WeatherHandler(BaseHTTPRequestHandler):
|
|||
self.end_headers()
|
||||
if response_body is not None:
|
||||
self.wfile.write(response_body)
|
||||
|
||||
|
||||
@cache
|
||||
def weather_handler(date: str):
|
||||
print(date)
|
||||
coordinates = [48.712, 44.514]
|
||||
url = (
|
||||
"https://api.open-meteo.com/v1/forecast?latitude="
|
||||
+ str(coordinates[0])
|
||||
+ "&longitude="
|
||||
+ str(coordinates[1])
|
||||
+ "¤t=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m"
|
||||
)
|
||||
raw_data = urllib.request.urlopen(url).read()
|
||||
# print(raw_data)
|
||||
return raw_data
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
from functools import cache
|
||||
import urllib.request
|
||||
|
||||
@cache
|
||||
def weather_handler(date: str):
|
||||
print(date)
|
||||
coordinates = [48.712, 44.514]
|
||||
url = (
|
||||
"https://api.open-meteo.com/v1/forecast?latitude="
|
||||
+ str(coordinates[0])
|
||||
+ "&longitude="
|
||||
+ str(coordinates[1])
|
||||
+ "¤t=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m"
|
||||
)
|
||||
raw_data = urllib.request.urlopen(url).read()
|
||||
return raw_data
|
Loading…
Reference in New Issue
Block a user