Home Page Microblog



Download 2,44 Mb.
Pdf ko'rish
bet10/17
Sana30.12.2021
Hajmi2,44 Mb.
#90837
1   ...   6   7   8   9   10   11   12   13   ...   17
Bog'liq
mega-tutorial

app

. The


app

package is defined by the app directory and the __init__.py script, and is referenced in the



from app import routes

statement. The



app

variable is defined as an instance of class



Flask

in the __init__.py script, which makes it a member of the



app

package.


Another peculiarity is that the

routes

module is imported at the bottom and not at the top

of the script as it is always done. The bottom import is a workaround to circular imports, a

common problem with Flask applications. You are going to see that the



routes

module needs

to import the

app

variable defined in this script, so putting one of the reciprocal imports at the

bottom avoids the error that results from the mutual references between these two files.

So what goes in the



routes

module? The routes are the different URLs that the application

implements. In Flask, handlers for the application routes are written as Python functions, called

view functions. View functions are mapped to one or more route URLs so that Flask knows

what logic to execute when a client requests a given URL.

Here is your first view function, which you need to write in the new module named app/routes.py:

Listing 1.2: app/routes.py

: Home page route


Download 2,44 Mb.

Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   ...   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish