示例#1
0
"""
import flask
from flask.views import MethodView
from index import Index
from browse import Browse
from form import Form
from submit import Submit

app = flask.Flask(__name__)       # our Flask app

"""
Function decorator === app.route('/',index())
"""

app.add_url_rule('/',
        view_func=Index.as_view('index'))

app.add_url_rule('/browse/',
        view_func=Browse.as_view('browse'),
        methods=['GET'])

app.add_url_rule('/form/',
        view_func=Form.as_view('form'))

app.add_url_rule('/submit/',
        view_func=Submit.as_view('submit'),
        methods=['POST'])

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
from index import Index
from form import Form
from shops import Shops
from reviews import Reviews
from translation import Translation

app = flask.Flask(__name__)  # our Flask app
"""
Route for main landing page. Accepts GET method
"""
app.add_url_rule("/", view_func=Index.as_view("index"), methods=["GET"])
"""
Route for form page. Accepts GET and POST methods
"""
app.add_url_rule("/form/",
                 view_func=Form.as_view("form"),
                 methods=["GET", "POST"])
"""
Route for shops (display) page. Accepts GET and POST methods
"""
app.add_url_rule("/shops/",
                 view_func=Shops.as_view("shops"),
                 methods=["GET", "POST"])
"""
Route for reviews (display) page. Accepts GET and POST methods
"""
app.add_url_rule(
    "/reviews/<shop_name>/<shop_phone>",
    view_func=Reviews.as_view("reviews"),
    methods=["GET", "POST"],
)