Modifications mineures
This commit is contained in:
parent
6320b99070
commit
60c79a05a9
1 changed files with 38 additions and 40 deletions
10
app.py
10
app.py
|
@ -12,16 +12,18 @@ app.config['TEMPLATES_AUTO_RELOAD'] = True
|
|||
|
||||
class Status(Enum):
|
||||
ERREUR_LIEN = "Le lien doit être en http ou https et valide !"
|
||||
ERREUR_INCONNUE = "Une erreur inconnue a été rencontrée !"
|
||||
BON = "Lien ajouté !"
|
||||
|
||||
def ecritureFichierHtml(nouvLien, cheminFichier):
|
||||
class Manip():
|
||||
def ecritureFichierHtml(nouvLien, cheminFichier):
|
||||
with open(cheminFichier, 'r+') as file:
|
||||
soup = BeautifulSoup(file, 'html.parser')
|
||||
soup.find("hr").insert_after("", nouvLien)
|
||||
file.seek(0)
|
||||
file.write(soup.prettify())
|
||||
|
||||
def valideUrl(url: str) -> bool:
|
||||
def valideUrl(url: str) -> bool:
|
||||
# thx django
|
||||
regex = re.compile(
|
||||
r'^(?:http|ftp)s?://' # http:// or https://
|
||||
|
@ -54,7 +56,6 @@ def bizutage_redirect():
|
|||
|
||||
@app.route("/bizutage", methods=["POST"])
|
||||
def bizutage():
|
||||
if request.method == "POST":
|
||||
lien = request.values['lien']
|
||||
if not valideUrl(lien):
|
||||
return render_template(
|
||||
|
@ -74,9 +75,6 @@ def bizutage():
|
|||
|
||||
ecritureFichierHtml(nouvLienHtml, "static/index.html")
|
||||
ecritureFichierHtml(nouvLienHtml, "lite/index.html")
|
||||
|
||||
else:
|
||||
print("error")
|
||||
return render_template("ajout.html", reussi=Status.BON.value)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue