Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix request api #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions interfaces/web/qutrub_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from glob import glob
import logging.config
from datetime import datetime, timedelta

from werkzeug.utils import import_string
sys.path.append(os.path.join(os.path.dirname(__file__), "./lib"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../"))

Expand All @@ -20,18 +22,28 @@


from flask import Flask, render_template, make_response, send_from_directory, request, jsonify, redirect
from flask_cors import cross_origin

from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

# ~ from flask_sitemap import Sitemap
from flask_minify import minify


app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0

minify(app=app, html=True, js=True, cssless=True)

limiter = Limiter(
app,
key_func=get_remote_address,
)


# ~ logging.config.fileConfig(LOGGING_CFG_FILE, disable_existing_loggers = False)
logging.basicConfig(filename=LOGGING_FILE, level=logging.DEBUG)

minify(app=app, html=True, js=True, cssless=True)


def str2bool(strg):
Expand Down Expand Up @@ -153,6 +165,8 @@ def ajax():
@app.route("/api/<verb>/<haraka>", methods=["GET"])
@app.route("/api/<verb>", methods=["GET"])
@app.route("/api", methods=["GET"])
@cross_origin()
@limiter.limit('60 per minute')
def api(text="", haraka=""):
default = "ضرب"
# ~ text = verb
Expand Down
47 changes: 25 additions & 22 deletions interfaces/web/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
black>=21.9b0
click>=8.0.3
Flask>=2.0.2
Flask-Minify>=0.32
htmlmin>=0.1.12
itsdangerous>=2.0.1
Jinja2>=3.0.2
jsmin>=3.0.0
lesscpy>=0.15.0
MarkupSafe>=2.0.1
mypy-extensions>=0.4.3
pathspec>=0.9.0
platformdirs>=2.4.0
ply>=3.11
PyArabic>=0.6.14
PyYAML>=6.0
regex>=2021.10.8
six>=1.16.0
tomli>=1.2.1
typing-extensions>=3.10.0.2
Werkzeug>=2.0.2
xxhash>=2.0.2
black==21.10b0
click==8.0.3
Flask==2.0.2
Flask-Cors==3.0.10
Flask-Limiter==1.4
Flask-Minify==0.32
htmlmin==0.1.12
itsdangerous==2.0.1
Jinja2==3.0.3
jsmin==3.0.0
lesscpy==0.15.0
limits==1.5.1
MarkupSafe==2.0.1
mypy-extensions==0.4.3
pathspec==0.9.0
platformdirs==2.4.0
ply==3.11
PyArabic==0.6.14
PyYAML==6.0
regex==2021.11.10
six==1.16.0
tomli==1.2.2
typing-extensions==4.0.0
Werkzeug==2.0.2
xxhash==2.0.2