web server(3)
-
go 언어로 web server 만들기 1 (고 언어 웹 서버)
고 언어로 웹 서버 만들기 시작 고 언어를 통해 간단히 web server를 만다는 법에 대해서 설명해 드리겠습니다. 우선 HTTP protocol 처리를 위해 "net/http"를 먼저 import 합니다. 또한 log 출력을 위해 fmt과 log도 import 합니다. import ( "net/http" "fmt" "log" )이후 다음과 같이 main 함수를 작성합니다. func handleRoot(res_writer http.ResponseWriter, req *http.Request) { fmt.Fprintf(res_writer, "welcome here %s!", r.URL.Path[1:]) } func main() { http.HandleFunc("/", handleRoot) res := h..
2021.12.30 -
Flask: update form value at JavaScript code
A form can be updated wih the new value at JavaScript code by accessing the form's id through DOM tree element. {{ form.hidden_tag() }} {{ form.name.label(class="form-control-label") }} ... in the HTML code, name form has its DOM element id as 'name'. Thus, in the JavaScript code, 'name' is used as DOM element id. function update_info(data) { document.getElementById('name').value = data.name .....
2021.08.14 -
JavaScript: AJAX call w/ Flask
JavaScript side First thing, you need to do to make an AJAX call from JavaScript is just adding ajax call code using jQuery as follow. AJAX server side At Flask server, what we need to implement to receive the POST request from client side is adding a new route function. from flask import Flask, render_template, jsonify, request app = Flask(__name__) @app.route('/') def index(): return render_te..
2021.08.14