自定路径处理
This commit is contained in:
parent
39eae65e25
commit
23616afd16
BIN
__pycache__/config.cpython-38.pyc
Normal file
BIN
__pycache__/config.cpython-38.pyc
Normal file
Binary file not shown.
12
main.py
12
main.py
@ -1,16 +1,26 @@
|
||||
import os
|
||||
import requests
|
||||
from flask import Flask, render_template, request, redirect, url_for, session
|
||||
from werkzeug.routing import BaseConverter
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
||||
class PhoneConverter(BaseConverter):
|
||||
regex = '1[3-9]\d{9}'
|
||||
|
||||
app.url_map.converters["phone"] = PhoneConverter
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
def index():
|
||||
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route("/<phone:param>")
|
||||
def phone(param):
|
||||
return param
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.config.from_pyfile("config.py")
|
||||
app.run(host="0.0.0.0")
|
Loading…
x
Reference in New Issue
Block a user