-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathmain.py
46 lines (31 loc) · 847 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, request
from views.products import products_app
app = Flask(__name__)
app.config.update(ENV="development")
app.register_blueprint(
products_app,
url_prefix="/products",
)
@app.route("/")
def hello_world():
# another_func()
return "<p>Hello, World!!</p>"
def another_func():
print(request)
print(request.path)
@app.route("/hello/")
def hello_view():
# another_func()
name = request.args.get("name", "World")
name = name.strip()
if not name:
name = "World"
return {"message": f"Hello {name}!"}
@app.route("/items/<int:item_id>/")
def get_item(item_id: int):
return {"item_id": item_id}
@app.route("/items/<string:item_id>/")
def get_item_str(item_id: str):
return {"item": {"id": item_id.lower()}}
if __name__ == '__main__':
app.run(debug=True)