44 Commits

Author SHA1 Message Date
RTAkland
31ea638770 feat: update version 2021-12-26 14:13:52 +08:00
RTAkland
11244734fd feat: update version 2021-12-26 14:13:31 +08:00
RTAkland
9cbd3b5063 feat: fix a bug 2021-12-26 14:13:09 +08:00
RTAkland
3622b094fd feat: add 404 page 2021-12-26 14:12:40 +08:00
RTAkland
4c73240fe9 feat: update language files 2021-12-26 14:12:24 +08:00
RTAkland
451aed59d0 feat: del 2021-12-26 10:34:10 +08:00
RTAkland
0b41c9c1f5 feat: update README.md 2021-12-26 10:00:07 +08:00
RTAkland
b205533ae7 feat: del 2021-12-26 09:39:03 +08:00
RTAkland
b493c06387 feat: update .gitignore 2021-12-26 09:36:33 +08:00
RTAkland
936dd14a87 feat: updated 2021-12-25 12:18:22 +08:00
RTAkland
21a7f9140d feat: updated 2021-12-25 12:15:13 +08:00
RTAkland
23f44c3f78 feat: fixed a bug 2021-12-25 12:14:53 +08:00
RTAkland
9477c33952 feat: update 2021-12-25 12:09:30 +08:00
RTAkland
7fdd0d56a1 feat: fixed a bug 2021-12-25 12:08:52 +08:00
RTAkland
2117771518 feat: update README.md 2021-12-24 19:52:11 +08:00
RTAkland
ea4d04a71c feat: add hitokoto 2021-12-24 19:51:49 +08:00
RTAkland
235e252bab feat: update README.md 2021-12-24 18:58:26 +08:00
RTAkland
278913b2c3 update language files 2021-12-24 18:57:25 +08:00
RTAkland
3cc8afa1f4 feat: optimized output information 2021-12-24 18:56:16 +08:00
RTAkland
3034346c73 feat: removed some text 2021-12-24 18:55:11 +08:00
RTAkland
7b4a0dd033 feat: update 2021-12-23 21:09:19 +08:00
RTAkland
c9ec788cd3 feat: update version 2021-12-21 21:37:53 +08:00
RTAkland
30240033cf feat: update language files 2021-12-21 21:37:33 +08:00
RTAkland
f986a037a8 feat: added SSL 2021-12-21 21:37:13 +08:00
RTAkland
1b96caf719 feat: fixed a bug 2021-12-21 21:36:29 +08:00
RTAkland
df1d5a13b4 feat: added a small info 2021-12-21 20:59:05 +08:00
RTAkland
2c111536c7 feat: update version 2021-12-21 20:57:56 +08:00
RTAkland
1bedb05ac1 feat: rename webserver -> webservice 2021-12-21 20:56:14 +08:00
RTAkland
fd10791baa feat: update language files 2021-12-21 20:55:39 +08:00
RTAkland
98b4b9305b feat: rename file 2021-12-21 20:55:09 +08:00
RTAkland
62d08096b3 feat: added get_host_ip.py 2021-12-21 20:54:38 +08:00
RTAkland
c32efe4b44 feat: added webservice host ip info 2021-12-21 20:54:02 +08:00
RTAkland
9e3f866fb8 feat: fixed a small bug 2021-12-21 20:53:35 +08:00
RTAkland
e8b1a910ae feat: fixed a bug 2021-12-20 22:03:49 +08:00
RTAkland
dd1dc2e3e6 feat: update README.md 2021-12-20 21:58:03 +08:00
RTAkland
bac4565289 feat: update requirements.txt -> space 2021-12-20 21:38:50 +08:00
RTAkland
25f755fd27 feat: update requirements.txt -> openpyxl 2021-12-20 21:25:40 +08:00
RTAkland
09ebfc1a76 feat: update config.yml 2021-12-20 21:25:23 +08:00
RTAkland
ee9e4a4c0f feat: update language files 2021-12-20 21:24:55 +08:00
RTAkland
c2bc49b0d4 feat: added an error collector 2021-12-20 21:24:26 +08:00
RTAkland
fe8d850422 feat: added some comments 2021-12-20 21:23:57 +08:00
RTAkland
51023efc76 feat: fixed a bug 2021-12-20 21:23:22 +08:00
RTAkland
0c6a267967 feat: added some comments 2021-12-20 21:23:10 +08:00
RTAkland
28e1319ee3 feat: fixed many bugs 2021-12-20 21:22:42 +08:00
22 changed files with 292 additions and 150 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
test.py
*.yml
!config.yml
*.log

View File

@@ -1,14 +1,14 @@
<p align="center">
<a href="https://github.com/MarkusJoe/QWeather">
<img src="https://img.shields.io/badge/Python-3.10.x-blue.svg" alt="PythonVersion">
<img src="https://img.shields.io/badge/release-3.1.0b-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/release-3.2.2-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/LINCESE-Apache2.0-orange.svg" alt="LICENSE">
</a>
</p>
<div align="center">
## *QWeather*
## *QWeatherReporter*
<i style="text-align: center;"><a href="https://www.qweather.com/">QWeather Official Website</a></i>\
<i style="text-align: center;"><a href="https://dev.qweather.com/">QWeather Development Platform</a></i>
@@ -20,32 +20,33 @@
<b><i><a href="https://markusjoe.github.io/" target="_blank">点击跳转到帮助文档</a></i></b>
</div>
## 声明
- > 程序作者: **RTAkland (markushammered@gmail.com)**
- > 和风天气开发者平台https://dev.qweather.com
- > 和风天气官网: https://qweather.com
### 开源
- 本项目以[Apache-2.0](./LICENSE)许可开源, 即:
- 你可以直接使用该项目提供的功能, 无需任何授权
- 你可以在**注明来源版权信息**的情况下对源代码进行任意分发和修改以及衍生
### 已实现功能
- [x] 发送免费版&开发板右键
- [x] 发送免费版&开发版天气预报功能
- [x] 间隔10分钟请求一次自然灾害预警信息
- [x] 在网页上快速查看天气
- [x] 在邮件html内附带一句一言
- [ ] ~~推送到QQ(咕咕咕)~~
### 问题汇总
#### Python 版本:
> 程序使用了Python3.10中的match-case语句
> 请使用Python3.10版本运行
> 程序使用了*Python3.10.x*中的match-case语句
> 请使用*Python3.10.x*版本运行
#### 主题选择:
> 在2.9.0之后的版本不支持自定义天气图标 只能使用最新的图标
#### 配置填写问题:
> `location`项和`only-view-settings`类不需要用户填写, 只需要打开`QWeather.py`进行自助填写
## 声明
- > 程序作者: **RTAkland (markushammered@gmail.com)**
- > 和风天气开发者平台https://dev.qweather.com
- > 和风天气官网: https://qweather.com
## 如何使用
- 程序基于python3.10开发 务必使用python3.10版本运行
- 将config.yml正确填写完成
@@ -54,8 +55,9 @@
### 网页上查看天气
- 将所有准备工作完成(能正常运行QWeather.py)
- 运行QWeather.py
- 打开浏览器输入***127.0.0.1***:7898 (127.0.0.1可以更改为部署本项目的服务器ip)
- 运行`QWeather.py`
- 打开浏览器输入**127.0.0.1:7898**
>127.0.0.1可以更改为部署本项目的服务器ip, 7898端口不能被其他程序占用或不开放此端口
## 联系方式

View File

@@ -103,7 +103,12 @@ client-settings:
# [选填/只能一个] 开启本地网页快速查看天气
# 默认: False
# 可选: "True" "False"
webserver: False
webservice: false
# [必填/只能一个] 是否使用SSL 连接到邮箱服务器
# 默认 True
# 可选: "True" "False"
SSL: True
# [标识/不填] 仅作用户读取标识
@@ -111,7 +116,7 @@ only-view-settings:
# 城市名
city-name: 黄岩-台州-台州
# 修改时间
time: Sun Dec 12 2021 14:49:38
time: Mon Dec 20 2021 21:08:22
# 修改用户
user: rtakland

View File

@@ -5,31 +5,8 @@
# @Create Time: 2021/12/15
# @File Name: __init__.py
"""
Check the configuration file
"""
import os
import sys
from core.logger import Logger
from core.language import Language
from core.read_config import read_config
settings = read_config()
if not os.path.exists('./logs'):
os.mkdir('./logs')
for mail in settings[0].values():
if not mail:
Logger.critical('mail-settings 有未填写项目')
sys.exit(1)
for request in settings[1].values():
if not request:
Logger.critical('request-settings 有未填写项目')
sys.exit(1)
for other in settings[1].values():
if not other:
Logger.critical('client-settings 有未填写项目')
sys.exit(1)

View File

@@ -6,7 +6,7 @@
# @File Name: information.py
import requests
from core import read_config
from core.read_config import read_config
class WeatherInfo:

View File

@@ -10,6 +10,10 @@ import json
def Language():
"""
读取配置文件中的语言选项并返回相对因的语言文件的读取结果
:return:
"""
with open('./config.yml', 'r', encoding='utf-8') as lang:
config = YAML().load(lang.read())
language_sel = config['client-settings']['language']

View File

@@ -13,7 +13,7 @@ import time
level = read_config()[2]['level']
date_format = '%H:%M:%S'
info_format_console = '%(log_color)s[%(asctime)s] |%(filename)s[ %(lineno)-3s] |%(levelname)-8s |%(message)s'
info_format_console = '%(log_color)s[%(asctime)s] |%(filename)s[%(lineno)-3s] |%(levelname)-8s |%(message)s'
info_format_file = '[%(asctime)s] |%(filename)s[%(funcName)sline:%(lineno)d] |%(levelname)-8s |%(message)s'
formatter = ColoredFormatter(fmt=info_format_console,
datefmt=date_format,

View File

@@ -13,14 +13,15 @@ from concurrent.futures import ProcessPoolExecutor
from core.logger import Logger
from core.language import Language
from core.settings import change_settings
from lib import webserver
from core import read_config
from core.read_config import read_config
from core.sendmail import Mail
from lib.webservice import accept_requests
def check_time():
"""
if the local time is the time in config, send a mail
通过多进程让函数和主程序并行,
并持续检测本地计算机时间是否和配置文件内填写的发送时间一致
:return:
"""
mode = settings[1]['mode']
@@ -46,7 +47,42 @@ def check_time():
time.sleep(60)
def check_config():
"""
返回配置文件中的location项是否填写
:return: True or False
"""
location = settings[1]['location']
if location:
return True
else:
return False
def setting():
"""
检查配置文件是否填写完成
:return:
"""
for mail in settings[0].values():
if not mail:
Logger.critical('mail-settings 有未填写项目')
sys.exit(1)
for request in settings[1].values():
if not request:
Logger.critical('request-settings 有未填写项目')
sys.exit(1)
for other in settings[1].values():
if not other:
Logger.critical('client-settings 有未填写项目')
sys.exit(1)
def main():
"""
主程序
:return:
"""
parser = argparse.ArgumentParser()
arg_keywords = ['free', 'dev', 'warning', 'setting']
parser.add_argument('-t',
@@ -69,13 +105,18 @@ def main():
Logger.debug(f'{language["debug_done"]}')
sys.exit(0)
case 'setting':
change_settings(False)
change_settings()
Logger.debug(f'{language["debug_done"]}')
case _:
pass
if check_config():
setting()
else:
change_settings()
processes.submit(check_time)
if settings[2]['webserver']:
processes.submit(webserver.process_request())
if settings[2]['webservice']:
Logger.info(f'{language["webservice_ip"]}:127.0.0.1:7898')
processes.submit(accept_requests())
time_count = 0
while True:

View File

@@ -10,10 +10,11 @@ from ruamel.yaml import YAML
def read_config():
"""
读取配置文件并返回读取到的内容同
:return: mail-settings, request-settings, client-settings, only-view-settings --> 0, 1, 2, 3
"""
with open('./config.yml', 'r') as conf:
config_file = 'config.yml'
with open(f'./{config_file}', 'r') as conf:
config = YAML().load(conf.read())
mail_settings = config['mail-settings']
request_settings = config['request-settings']

View File

@@ -12,7 +12,7 @@ from core.language import Language
def read_excel(kw: str):
"""
Read xlsx file and return searched results
读取china_city_list.xlsx并搜索匹配关键字的结果并输出到终端
:param kw: keyword
:return: city_list
"""

View File

@@ -16,6 +16,7 @@ from core.logger import Logger
from core.language import Language
from core.information import WeatherInfo
from core.read_config import read_config
from lib.hitokoto import hitokoto
class Mail:
@@ -33,12 +34,18 @@ class Mail:
self.message['From'] = Header('QWeather') # 发件人名称
self.message['To'] = Header('All allowed User') # 收件人显示名称
self.hitokoto = hitokoto() # 一言
if self.enableSSL:
self.smtp = smtplib.SMTP_SSL(self.server, self.port) # 登录服务器 使用SSL连接
else:
self.smtp = smtplib.SMTP(self.server, self.port) # 登录邮箱服务器 不使用SSL连接
def dev_version(self):
"""
开发者版本
:return:
"""
dev_weather = WeatherInfo().dev_version()
dates = dev_weather[0]
day_weathers = dev_weather[1]
@@ -124,8 +131,8 @@ class Mail:
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>相对湿度</th>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -138,8 +145,8 @@ class Mail:
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -162,9 +169,13 @@ class Mail:
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<br />
<div style="text-align: center" id="hitokoto">
<p>
{self.hitokoto}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
@@ -203,6 +214,10 @@ class Mail:
sys.exit(1)
def free_version(self):
"""
免费版本
:return:
"""
free_weather = WeatherInfo().free_version()
dates = free_weather[0]
day_weathers = free_weather[1]
@@ -263,8 +278,8 @@ class Mail:
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>相对湿度</th>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -277,8 +292,8 @@ class Mail:
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -301,9 +316,13 @@ class Mail:
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<br />
<div style="text-align: center" id="hitokoto">
<p>
{self.hitokoto}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
@@ -342,6 +361,10 @@ class Mail:
sys.exit(1)
def warning_(self):
"""
自然灾害预警
:return:
"""
info = WeatherInfo().warning_()
release_time = info[0]
title = info[1]

View File

@@ -11,62 +11,60 @@ import getpass
from core.logger import Logger
from core.language import Language
from core.read_excel import read_excel
from core.read_config import read_config
from ruamel.yaml import YAML
def change_settings(flag: bool = True):
def change_settings():
"""
:return: None
使用read_excel.py搜索到的结果再次进行二次选择, 并写入文件
:return:
"""
language = Language()
settings = read_config()
if not settings[1]['mode'] or not flag:
Logger.info(f'[Modify]{language["fill_the_config"]}')
Logger.info(f'[Modify]{language["input_a_city_name"]}')
while True:
time.sleep(0.3)
city_name = input('-->')
match city_name:
case 'q':
Logger.info(f'[Modify]User quit.')
sys.exit(0)
case '':
Logger.critical(f'[Modify]{language["null_value"]}')
continue
case _:
break
searched_city = read_excel(city_name)
Logger.info(f'[Modify]{language["user_input"]}:[{city_name}]')
Logger.info(f'[Modify]{language["select_a_index"]}')
if not searched_city:
Logger.error(f'[Modify]{language["no_result"]}')
sys.exit(1)
Logger.info(f'[Modify]{language["change_setting"]}')
Logger.info(f'[Modify]{language["fill_the_config"]}')
Logger.info(f'[Modify]{language["input_a_city_name"]}')
while True:
time.sleep(0.3)
while True:
try:
time.sleep(0.3)
user_input = input('-->')
if user_input == 'q':
Logger.info('[Quit]User quit')
sys.exit(1)
index = searched_city[int(user_input)]
with open('./config.yml', 'r', encoding='utf-8') as of:
data = YAML().load(of)
data['request-settings']['location'] = index[1]
data['only-view-settings']['city-name'] = f'{index[3]}-{index[7]}-{index[7]}'
data['only-view-settings']['time'] = time.strftime("%a %b %d %Y %H:%M:%S", time.localtime())
data['only-view-settings']['user'] = getpass.getuser()
with open('./config.yml', 'w', encoding='utf-8') as wf:
YAML().dump(data, wf)
Logger.info(f'[Write]{language["write_successfully"]}:config.yml')
break
except (IndexError, ValueError) as e:
Logger.info(e)
Logger.error(f'[Write]{language["input_type_error"]}')
continue
finally:
Logger.info('[Done]Program has done.')
city_name = input('-->')
match city_name:
case 'q':
Logger.info(f'[Exit]{language["exit"]}')
sys.exit(0)
case '':
Logger.error(f'[Modify]{language["null_value"]}')
continue
case _:
break
searched_city = read_excel(city_name)
Logger.info(f'[Modify]{language["user_input"]}:[{city_name}]')
Logger.info(f'[Modify]{language["select_a_index"]}')
if not searched_city:
Logger.error(f'[Modify]{language["no_result"]}')
sys.exit(1)
time.sleep(0.3)
while True:
try:
time.sleep(0.3)
user_input = input('-->')
if user_input == 'q':
Logger.info(f'[Exit]{language["exit"]}')
sys.exit(1)
index = searched_city[int(user_input)]
with open('./config.yml', 'r', encoding='utf-8') as of:
data = YAML().load(of)
data['request-settings']['location'] = index[1]
data['only-view-settings']['city-name'] = f'{index[3]}-{index[7]}-{index[7]}'
data['only-view-settings']['time'] = time.strftime("%a %b %d %Y %H:%M:%S", time.localtime())
data['only-view-settings']['user'] = getpass.getuser()
with open('./config.yml', 'w', encoding='utf-8') as wf:
YAML().dump(data, wf)
Logger.info(f'[Write]{language["write_successfully"]}:config.yml')
break
except (IndexError, ValueError) as e:
Logger.info(e)
Logger.error(f'[Write]{language["input_type_error"]}')
continue
finally:
Logger.info(f'[Exit]{language["exit"]}')
sys.exit(0)

View File

@@ -16,6 +16,10 @@ import json
def hourly_weather():
"""
获取24小时的天气
:return:
"""
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']

View File

@@ -17,6 +17,10 @@ import json
def indices():
"""
获取生活建议
:return:
"""
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']

View File

@@ -16,6 +16,10 @@ import json
def real_time_air_quality():
"""
获取实时的空气质量数据
:return:
"""
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']

View File

@@ -16,6 +16,11 @@ import json
def get_warning_list(_range='cn'):
"""
获取当前正在发送自然灾害的城市id列表
:param _range: Range
:return:
"""
settings = read_config()
key = settings[1]['key']
r = requests.get(f'https://devapi.qweather.com/v7/warning/list?range={_range}&key={key}')

23
lib/hitokoto.py Normal file
View File

@@ -0,0 +1,23 @@
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/24
# @File Name: hitokoto.py
import requests
from core.language import Language
from core.logger import Logger
def hitokoto():
language = Language()
url = 'https://v1.hitokoto.cn/'
Logger.info(f'{language["hitokoto"]}')
res = requests.get(url).json()
speaker = res['from_who']
text = res['hitokoto']
if not speaker:
speaker = language['noname']
full_text = f'{text} --{speaker}'
return full_text

View File

@@ -3,22 +3,29 @@
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/18
# @File Name: webserver.py
# @File Name: webservice.py
import socket
import sys
import threading
from core.logger import Logger
from core.read_config import read_config
from core.information import WeatherInfo
from core.language import Language
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('127.0.0.1', 7898))
server.bind(('0.0.0.0', 7898))
server.listen(5)
language = Language()
def build_html():
"""
构建html主体
:return:
"""
settings = read_config()
city = settings[3]['city-name']
mode = settings[1]['mode']
@@ -47,7 +54,7 @@ def build_html():
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<p style="text-align: center"><i><b>地区:{city}</b></i></p>
@@ -115,8 +122,8 @@ def build_html():
<th>&nbsp;</th>
</tr>
<tr>
<th>风速//</th>
<th>相对湿度</th>
<th>风速//</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -129,8 +136,8 @@ def build_html():
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -192,7 +199,7 @@ def build_html():
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<p style="text-align: center"><i><b>地区:{city}</b></i></p>
@@ -245,8 +252,8 @@ def build_html():
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -288,25 +295,40 @@ def build_html():
return "You hadn't selected a mode"
def process_request():
def process_requests(c, a):
"""
处理请求
:param c: connection
:param a: address
:return:
"""
try:
while True:
c, a = server.accept()
data = str(c.recv(1024)).split(':')[0][6:][:-17]
html = build_html()
if data == '/':
c.send('HTTP1.1/ 200 OK\r\n\r\n'.encode('utf-8'))
c.send(html.encode('utf-8'))
Logger.info(f'{a}: Get {data} --by browser')
else:
try:
with open(f'.{data}', 'rb') as f:
c.send('HTTP1.1/ 200 OK\r\n\r\n'.encode('utf-8'))
c.send(f.read())
Logger.info(f'{a}: Get {data} --by browser')
except FileNotFoundError:
c.send(f'HTTP1.1/ 404 Not Found\r\n\r\n{html}'.encode('utf-8'))
c.close()
data = str(c.recv(1024)).split(':')[0][6:][:-17]
html = build_html()
if data == '/': # 判断用户请求的目标是否为根目录, 如果是则返回html; 如果不是则继续判断
c.send('HTTP/1.1 200 OK\r\n\r\n'.encode('utf-8'))
c.send(html.encode('utf-8'))
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
try:
with open(f'./{data}', 'rb') as f:
c.send('HTTP/1.1 200 OK\r\n\r\n'.encode('utf-8'))
c.send(f.read())
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
except FileNotFoundError:
with open('./res/basic-resources/404.html', 'r') as not_found:
c.send(f'HTTP/1.1 404 Not Found\r\n\r\n{not_found.read()}'.encode('utf-8'))
except BrokenPipeError:
Logger.critical('Link speed was too fast! Subprocess:webserver exited')
sys.exit(1)
Logger.error(f'{language["connection_speed_too_fast"]}')
finally:
c.close()
return
def accept_requests():
"""
接受请求
:return:
"""
while True:
c, a = server.accept()
threading.Thread(target=process_requests, args=(c, a,)).start()

View File

@@ -1,4 +1,5 @@
requests==2.26.0
ruamel.yaml==0.17.17
pandas==1.3.4
colorlog==6.5.0
requests>=2.26.0
ruamel.yaml>=0.17.17
pandas>=1.3.4
colorlog>=6.5.0
openpyxl>=3.0.9

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<i><b><p style="text-align: center; color: red">404 File Not Found</p></b></i>
</body>
</html>

View File

@@ -28,5 +28,14 @@
"no_result": "Nothing has searched.",
"config_file_read_successfully": "Read config file successfully.",
"language_file_read_successfully": "Multi-language module load successfully",
"language_not_filled": "Language hasn't filled, default: zh_cn"
"language_not_filled": "Language hasn't filled, default: zh_cn.",
"no_location": "You haven't fill the location in the config file.",
"change_setting": "You are changing setting.",
"exit": "Exited.",
"webservice_ip": "Local webservice ip",
"connection_speed_too_fast": "Connection speed is too fast",
"noname": "No name.",
"hitokoto": "Get hitokoto successfully.",
"get_resource": "Get resource",
"get_resource_from": "from"
}

View File

@@ -28,5 +28,13 @@
"no_result": "没有搜索到相关结果",
"config_file_read_successfully": "配置文件读取成功",
"language_file_read_successfully": "多语言模块加载成功",
"language_not_filled": "语言选项为填写完成或填写错误, 默认zh_cn"
}
"language_not_filled": "语言选项为填写完成或填写错误, 默认zh_cn",
"change_setting": "更改设置",
"exit": "已退出",
"webservice_ip": "webservice地址",
"connection_speed_too_fast": "连接速度过快",
"noname": "佚名",
"hitokoto": "一言获取成功",
"get_resource": "获取资源",
"get_resource_from": "来自"
}