To create a series of things, such as a project, all save points
# coding = Utf-8
# flask is a python-written web micro-framework that enables you to quickly implement a Web site or Web service using the Python language.
From flask import Flask
# Initialize Flask
App = Flask (__name__)
# The route access path created is empty
@app. Route ("/")
Def home ():
Return to "Hello World"
# App.run () code is optional The default port number is 5000, personal preference
if __name__ = = "__main__":
App.run (host= "localhost", port= ", debug=true)
Normal operation result
If you are returning an HTML page, import send_file
From flask Import Send_file
@app. Route ("/")
Def home ():
Return Send_file (".. /static/index.html ")
Web page back to normal because there's only one helloword on this side, index.html.
Loading when the introduction of CSS, JS, static pictures, etc... needs to be handled.
Create a folder at the root of the project put all the static resources into the access path by default change to/static/xxx/xxx.css or
/static/xxx/xxx.jpg, etc.
The final result of the visit is
Static resources are documented.
Of course, you can also use url_for constructs, such as code
Url_for ("Static", Filename= "Css/demo.css")
The first web environment built by python