Sfoglia il codice sorgente

Step 01.2: / redirects to /contacts.

Frédéric G. MARAND 6 mesi fa
parent
commit
ab7878088b
4 ha cambiato i file con 15 aggiunte e 4 eliminazioni
  1. 6 0
      .idea/demo-htmx.iml
  2. 6 0
      .idea/misc.xml
  3. 2 1
      contactsapp/app.go
  4. 1 3
      contactsapp/app.py

+ 6 - 0
.idea/demo-htmx.iml

@@ -1,10 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="WEB_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="Python" name="Python facet">
+      <configuration sdkName="Python 3.9" />
+    </facet>
+  </component>
   <component name="Go" enabled="true" />
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="htmx.org" level="application" />
+    <orderEntry type="library" name="Python 3.9 interpreter library" level="application" />
   </component>
 </module>

+ 6 - 0
.idea/misc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Black">
+    <option name="sdkName" value="Python 3.9" />
+  </component>
+</project>

+ 2 - 1
contactsapp/app.go

@@ -15,11 +15,12 @@ const (
 def index():
 */
 func RouteIndex(w http.ResponseWriter, r *http.Request) {
-	w.Write([]byte("Hello World!"))
+	http.Redirect(w, r, "/contacts", http.StatusSeeOther)
 }
 
 func setupRoutes(mux *http.ServeMux) {
 	mux.HandleFunc("/", RouteIndex)
+	mux.Handle("/contacts", http.NotFoundHandler())
 }
 
 func main() {

+ 1 - 3
contactsapp/app.py

@@ -1,9 +1,7 @@
 from flask import (
-    Flask, redirect, render_template, request, flash, jsonify, send_file
+    Flask, redirect
 )
 
-from contacts_model import Contact, Archiver
-
 # ========================================================
 # Flask App
 # ========================================================