5 Commits

Author SHA1 Message Date
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
6 changed files with 58 additions and 33 deletions

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.3b-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/release-3.1.4b-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,6 +20,12 @@
<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)许可开源, 即:
- 你可以直接使用该项目提供的功能, 无需任何授权
@@ -40,12 +46,6 @@
#### 配置填写问题:
> `location`项和`only-view-settings`类不需要用户填写, 只需要打开`QWeather.py`进行自助填写
## 声明
- > 程序作者: **RTAkland (markushammered@gmail.com)**
- > 和风天气开发者平台https://dev.qweather.com
- > 和风天气官网: https://qweather.com
## 如何使用
- 程序基于python3.10开发 务必使用python3.10版本运行
- 将config.yml正确填写完成
@@ -55,7 +55,8 @@
### 网页上查看天气
- 将所有准备工作完成(能正常运行QWeather.py)
- 运行QWeather.py
- 打开浏览器输入***127.0.0.1***:7898 (127.0.0.1可以更改为部署本项目的服务器ip)
- 打开浏览器输入**127.0.0.1:7898**
>127.0.0.1可以更改为部署本项目的服务器ip, 7898端口不能被其他程序占用或不开放此端口
## 联系方式

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,6 +34,8 @@ 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:
@@ -128,8 +131,8 @@ class Mail:
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>相对湿度</th>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -142,8 +145,8 @@ class Mail:
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -166,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>
@@ -271,8 +278,8 @@ class Mail:
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>相对湿度</th>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -285,8 +292,8 @@ class Mail:
</tr>
<tr>
<th>能见度</th>
<th>大气压强</th>
<th>相对云量</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
@@ -309,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>

5
lib/hitokoto.py Normal file
View File

@@ -0,0 +1,5 @@
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/24
# @File Name: hitokoto.py

View File

@@ -54,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>
@@ -122,8 +122,8 @@ def build_html():
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>相对湿度</th>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
@@ -136,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>
@@ -199,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>
@@ -252,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>
@@ -308,13 +308,13 @@ def process_request():
if data == '/': # 判断用户请求的目标是否为根目录, 如果是则返回html; 如果不是则继续判断
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')
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
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')
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
except FileNotFoundError:
c.send(f'HTTP1.1/ 404 Not Found\r\n\r\n{html}'.encode('utf-8'))
c.close()

View File

@@ -34,5 +34,9 @@
"exit": "Exited.",
"webservice_ip": "Local webservice ip",
"connection_speed_too_fast": "Connection speed is too fast, subprocess: webservice has exited.",
"an_io_error": "An IO error."
"an_io_error": "An IO error.",
"noname": "No name.",
"hitokoto": "Get hitokoto successfully.",
"get_resource": "Get resource",
"get_resource_from": "from"
}

View File

@@ -33,5 +33,9 @@
"exit": "已退出",
"webservice_ip": "webservice地址",
"connection_speed_too_fast": "连接速度过快, 子进程:webservice.py 已退出",
"an_io_error": "一个IO错误"
"an_io_error": "一个IO错误",
"noname": "佚名",
"hitokoto": "一言获取成功",
"get_resource": "获取资源",
"get_resource_from": "来自"
}