sitemap + robots

This commit is contained in:
artem 2023-05-09 09:46:03 +03:00
parent 0868e73301
commit 2f50a00f78
2 changed files with 38 additions and 2 deletions

View File

@ -2,7 +2,7 @@
from PIL import Image
from sanic import Sanic
from sanic.response import json as json_answer
from sanic.response import json as json_answer, text
import numpy as np
from tensorflow import keras
from tensorflow.keras.utils import img_to_array
@ -49,7 +49,10 @@ def get_images():
IMAGES[item.get("text")] = s.get("url")
break
get_images()
@app.post("/beeds")
async def beeds(request):
body = request.files.get("f").body
@ -97,5 +100,38 @@ async def beeds(request):
})
sitemap_data = '''<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
<url>
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/</loc>
<lastmod>2023-05-01T19:01:03+00:00</lastmod>
</url>
</urlset>
'''
@app.get("/sitemap.xml")
async def sitemaps(request):
return text(sitemap_data, content_type="application/xml")
robots_data = '''
User-agent: *
Allow: /
Sitemap: https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/sitemap.xml
'''
@app.get("/robots.txt")
async def robots(request):
return text(robots_data)
if __name__ == "__main__":
app.run(auto_reload=True, port=4003, host="0.0.0.0")

View File

@ -5,7 +5,7 @@ async function SavePhoto() {
document.getElementById("result").innerHTML = "";
let photo = document.getElementById("file-input").files[0];
let formData = new FormData();
// TODO: пройтись по всем результатм - если совпадают дважды - поднять вверх
formData.append("f", photo);
let response = await fetch('/beeds', { method: "POST", body: formData });
if (response.ok) {