exec/aruudy_flask
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2019 Abdelkrime Aries <kariminfo0@gmail.com>
#
# ---- AUTHORS ----
# 2019 Abdelkrime Aries <kariminfo0@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import Flask
#from flask import render_template, request
from flask import render_template_string, request
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from aruudy.web.api import aruudy_api
app = Flask(__name__)
app.register_blueprint(aruudy_api)
app.config["JSON_AS_ASCII"] = False
res = u"""
<html>
<head>
<title>Testing Aruudy</title>
<meta charset="UTF-8">
<style></style>
</head>
<body>
<h1>Arabic prosody</h1>
<h2>Info about available meters</h2>
<p>
Using <b>"$host/ls"</b>.
<br>Try this:
<a href="./ls" target="_blank">
{{ host }}ls
</a>
</p>
<h2>Info about a specific meter</h2>
<p>
Using <b>"$host/info/[name]"</b>.
The name can be in Arabic or English.
<br>Try this:
<a href="./info/long" target="_blank">
{{ host }}info/long
</a>
<br>Or, this:
<a href="./info/كامل" target="_blank">
{{ host }}info/كامل
</a>
</p>
<h2>Processing a verse's part (shatr)</h2>
<p>
Using <b>"$host/shatr/[text]"</b>.
<br>Try this:
<a href="./shatr/أَسِرْبَ%20القَطا%20هَلْ%20مَنْ%20يُعِيْرُ%20جَناحَهُ" target="_blank">
{{ host }}shatr/أَسِرْبَ%20القَطا%20هَلْ%20مَنْ%20يُعِيْرُ%20جَناحَهُ
</a>
</p>
</body>
</html>
"""
@app.route("/", methods=["GET", "POST"])
def index():
#return render_template("index.htm", host = request.host_url)
return render_template_string(res, host = request.host_url)
if __name__ == "__main__":
app.run()