mirror of
https://github.com/adanrsantos/ThePlaceHolders.git
synced 2024-12-16 14:20:39 -06:00
Merge branch 'main' of https://github.com/adanrsantos/ThePlaceHolders
This commit is contained in:
commit
542640c600
BIN
ThePlaceHolders
Executable file
BIN
ThePlaceHolders
Executable file
Binary file not shown.
33
server.go
33
server.go
|
@ -8,8 +8,34 @@ import (
|
||||||
const ADDRESS = "127.0.0.1"
|
const ADDRESS = "127.0.0.1"
|
||||||
const PORT = "8080"
|
const PORT = "8080"
|
||||||
|
|
||||||
func get_canvas(w http.ResponseWriter, r *http.Request) {
|
type UserForm struct {
|
||||||
fmt.Fprintf(w, "test data")
|
Email string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
func extract_user_data(r *http.Request) UserForm {
|
||||||
|
return UserForm{
|
||||||
|
Email: r.FormValue("email"),
|
||||||
|
Password: r.FormValue("password"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handle_login(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != http.MethodPost {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data := extract_user_data(r)
|
||||||
|
fmt.Fprintln(w, data.Email)
|
||||||
|
fmt.Fprintln(w, data.Password)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handle_register(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != http.MethodPost {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data := extract_user_data(r)
|
||||||
|
fmt.Fprintln(w, data.Email)
|
||||||
|
fmt.Fprintln(w, data.Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -18,7 +44,8 @@ func main() {
|
||||||
http.Handle("/", static_files)
|
http.Handle("/", static_files)
|
||||||
|
|
||||||
// Response generated by code
|
// Response generated by code
|
||||||
http.HandleFunc("/get-canvas", get_canvas)
|
http.HandleFunc("/handle-register", handle_register)
|
||||||
|
http.HandleFunc("/handle-login", handle_login)
|
||||||
|
|
||||||
// Start web server at 127.0.0.1:8080
|
// Start web server at 127.0.0.1:8080
|
||||||
e := http.ListenAndServe(ADDRESS+":"+PORT, nil)
|
e := http.ListenAndServe(ADDRESS+":"+PORT, nil)
|
||||||
|
|
|
@ -18,17 +18,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="exampleInputPassword1" class="form-label">Password</label>
|
<label for="exampleInputPassword1" class="form-label">Password</label>
|
||||||
<input type="password" class="form-control" id="exampleInputPassword1">
|
<input type="password" class="form-control" id="exampleInputPassword1" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 form-check">
|
<div class="mb-3 form-check">
|
||||||
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
<input type="checkbox" class="form-check-input" id="exampleCheck1" required>
|
||||||
<label class="form-check-label" for="exampleCheck1">Show Password</label>
|
<label class="form-check-label" for="exampleCheck1">Show Password</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="fs-6">
|
<div class="fs-6">
|
||||||
Already have an account? Click <a href="login.html">here</a> to login.
|
Already have an account? Click <a href="login.html">here</a> to login.
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<input type="submit" class="btn btn-primary" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue