def init_app(): app = Flask(__name__, static_folder="./static", template_folder="./templates") app.config.from_pyfile('setting.py') app.add_url_rule("/login", view_func=LoginView.as_view("login"), methods=["POST"]) app.add_url_rule("/logout", view_func=LogoutView.as_view("logout"), methods=["POST"]) app.add_url_rule("/market", view_func=MarketView.as_view("market"), methods=["POST", "PUT"]) app.add_url_rule("/order_solve", view_func=OpenOrderView.as_view("order_solve"), methods=["GET", 'POST', 'DELETE']) app.add_url_rule("/auth_code", view_func=AuthCodeView.as_view("auth_code"), methods=['PUT']) app.add_url_rule("/strategy", view_func=StrategyView.as_view("strategy"), methods=['GET', 'PUT', 'DELETE']) app.add_url_rule("/check_code", view_func=CheckCode.as_view("check_code"), methods=['POST']) app.add_url_rule("/run_code", view_func=RunCode.as_view("run_code"), methods=['POST']) app.add_url_rule("/code", view_func=CodeManage.as_view("code"), methods=['GET', 'POST']) app.add_url_rule("/close_position", view_func=PositionView.as_view("close_position"), methods=['POST']) app.add_url_rule("/bar", view_func=BarView.as_view("bar"), methods=['POST']) app.add_url_rule("/config", view_func=ConfigView.as_view("config"), methods=['GET', 'PUT']) GlobalVar.init_app(app) G.load_authorization() io.init_app(app) def emit_wrap(emit): def wrapp(event, *args, **kwargs): kwargs['room'] = 'vip' emit(event, *args, **kwargs) return wrapp io.emit = emit_wrap(io.emit) CORS(app) return app
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf.urls import url from django.contrib import admin from django.urls import path from app import views from app.models.person import Person from app.views import IndexView, RegisterView, PersonSearchView, PersonSearchTagView, LoginView, ProfileView, \ LogoutView, ProfilSearchView # from core import views as core_views urlpatterns = [ path('admin/', admin.site.urls), url(r'^$', PersonSearchView.as_view(), name='app_index'), url(r'register/$', views.signup, name='app_register_view'), url(r'logout/$', LogoutView.as_view(), name='app_register_view'), url('profil/view', ProfileView.as_view(), name='app_profile_view'), path('profil/tag/<int:pk>', ProfilSearchView.as_view(), name='app_profile_search_tag'), url(r'login/$', LoginView.as_view(), name='app_login_view'), path('person/tag/<int:pk>', PersonSearchTagView.as_view(), name='app_cocktail_search_tag') ]
from django.conf.urls import url from django.contrib import admin from django.urls import path, include, re_path from app.views import IndexView, ListMoviesView, LoginView, LogoutView, SignUpView, DetailMovieView, SearchFormView urlpatterns = [ path('i18n/', include('django.conf.urls.i18n')), path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index_view'), path('movies/', ListMoviesView.as_view(), name='list_movies_view'), re_path('^movies/letter/(?P<letter>\D+)', ListMoviesView.as_view(), name='list_movies_view'), path('movies/<int:pk>', DetailMovieView.as_view(), name='detail_movie_view'), path('login/', LoginView.as_view(), name='login_view'), path('logout/', LogoutView.as_view(), name='logout_view'), path('signup/', SignUpView.as_view(), name='signup_view'), path('search/', SearchFormView.as_view(), name='search_form_view'), ]
from django.urls import path, re_path from app.views import ReadingView, SeriesView, LoginView, LogoutView from django.contrib import admin urlpatterns = [ re_path(r'^(?P<pk>\d+\.\d+)/readings/$', ReadingView.as_view(), name='reading_list'), re_path(r'^$', SeriesView.as_view(), name='series_list'), re_path(r'^admin/', admin.site.urls), re_path(r'^login/$', LoginView.as_view(), name='login'), re_path(r'^logout/$', LogoutView.as_view(), name='logout'), ]
from django.conf import settings from app.models import InstagramUser from django.views.generic import ListView from django.conf.urls import patterns, url, include from app.views import IndexView, RegisterView, LoginView, LogoutView, AccountView, AccountSearch, PostView, fun urlpatterns = patterns('', (r'^/?$', IndexView.as_view()), (r'^register/?$', RegisterView.as_view()), (r'^login/?$', LoginView.as_view()), (r'^logout/?$', LogoutView.as_view()), (r'^posts/view/(?P<pk>[-_\w]+)/?$', PostView.as_view()), (r'^accounts/(?P<slug>[-_\w]+)/?$', AccountView.as_view()), (r'^search/(?P<query>\w+)/$', AccountSearch.as_view()), (r'^search/$', AccountSearch.as_view()), (r'^s3cret/$', fun) ) if settings.DEBUG: urlpatterns += patterns('', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT }), )
from django.contrib import admin from django.conf.urls import url from app import views import app from django.conf import settings from django.views.static import serve urlpatterns = [ # 基于函数 的 View 映射 URL 方法 #path('register/',RegisterView.as_view(),name='register'), url(r'^admin/', admin.site.urls), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^register/$', RegisterView.as_view(), name='register'), url(r'^main/$', MainView.as_view(), name='main'), url(r'^person_info/$', Person_info.as_view(), name='person_info'), url(r'^logout/', LogoutView.as_view(), name='logout'), url(r'^save_todo/$', views.save_todo), url(r'^save_memo/$', views.save_memo), url(r'^save_hide_todo/$', views.save_hide_todo), url(r'^$', IndexView.as_view(), name='index'), url(r'^page_not_found', views.page_not_found), url(r'^not_open', views.not_open, name='not_open'), ] # 全局 404 页面配置(django 会自动调用这个变量) handler404 = 'app.views.page_not_found' """ if settings.DEBUG: # debug_toolbar 插件配置 import debug_toolbar urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls))) else:
from django.conf.urls import url from app.views import SignupView,LoginView,LogoutView urlpatterns = [ url(r'Signup',SignupView.as_view()), url(r'Login',LoginView.as_view()), url(r'Logout',LogoutView.as_view()) ]
url(r'^admin/', admin.site.urls), url(r'^$', SchoolView.as_view(), name="index"), url(r'^class/(?P<school_class>(\d)+)', SchoolClassView.as_view(), name="school-class"), url(r'^student/(?P<student_id>(\d)+)', StudentView.as_view(), name="student_details"), url(r'^grades/(?P<student_id>(\d)+)/(?P<subject_id>(\d)+)', Grades.as_view(), name="student_grades"), url(r'^student_search', StudentSearchView.as_view(), name="student_search"), url(r'^add_student', AddStudentView.as_view(), name="add_student"), url(r'^pizza_toppings', PizzaToppings.as_view()), url(r'^class_presence/(?P<student_id>(\d)+)/(?P<date>\d{4}-\d{2}-\d{2})$', PresenceListView.as_view(), name="class_presence"), url(r'd2_p3_e1', UserDataView.as_view(), name="class_presence"), url(r'create_school_subject', SchoolSubjectCreateView.as_view(), name="create_school_subject"), url(r'compose_message', MessageFormView.as_view(), name="compose_message"), url(r'list_users', UserListView.as_view(), name="list_users"), url(r'login', LoginView.as_view(), name="login"), url(r'logout', LogoutView.as_view(), name="logout"), url(r'reset_password/(?P<user_id>(\d)+)$', ChangePassView.as_view(), name="reset_password"), ]
SearchIdeaByContent, UserSignupView, NormalLoginView, LoginSignup, UserIdeaView, FCMRegisterDeviceView, MyCommentsView, ) from rest_framework import routers router = routers.DefaultRouter() urlpatterns = [ path("post_ideas/", PostIdeaView.as_view()), path("published_ideas/", PublishedIdeasView.as_view()), path("view_idea/<int:pk>/", ViewIdea.as_view()), path("login/", SocialLoginView.as_view()), path("logout/", LogoutView.as_view()), path("vote/", VoteView.as_view()), path("comment/", CommentView.as_view()), path("comment/<int:pk>/", CommentView.as_view()), path("search_published_ideas/", SearchIdeaByContent.as_view()), path("normal_login/", NormalLoginView.as_view()), path("signup/", UserSignupView.as_view()), path("login_signup/", LoginSignup.as_view()), path("user_idea/", UserIdeaView.as_view()), path("user_idea/<int:pk>/", UserIdeaView.as_view()), path("register_device/", FCMRegisterDeviceView.as_view()), path("user_comments/", MyCommentsView.as_view()), ]