...
 
Commits (2)
.idea/
conf.json
sever_conf.json
server_conf.json
histories/
__pycache__/
......
from flask import Flask, request, abort
from flask import Flask, request, abort, g
import json
from cryptography.fernet import Fernet
from markupsafe import escape
......@@ -6,8 +6,6 @@ import requests
import telegram_notificator
import os
key = Fernet.generate_key()
f = Fernet(key)
try:
script_path = os.path.dirname(os.path.realpath(__file__))
......@@ -30,8 +28,7 @@ app = Flask(__name__)
@app.route("/<string:code>/", methods=["POST"])
def get_chat_id(code):
data = escape(code)
chat_id = f.decrypt(bytes(data, encoding="utf-8"))
chat_id = escape(code)
website_html = ""
......@@ -60,9 +57,8 @@ def send_link():
if chat_id is None:
abort(404)
token = f.encrypt(bytes(data, encoding="utf-8"))
url = application_website + "/" + token + "/"
url = application_website + "/" + str(chat_id) + "/"
telegram = telegram_notificator.TelegramNotificator(telegram_api_key, str(chat_id))
telegram.send(url)
......@@ -75,5 +71,6 @@ if __name__ == "__main__ ":
# openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
# To run the server:
# flask run --cert=cert.pem --key=key.pem
app.run(ssl_context=('cert.pem', 'key.pem'))
\ No newline at end of file
\ No newline at end of file