Cookie request
| | `req_cookie`[^name]=`req_cookie`[^value] | |
--- title: web-net-site description: Home + /about + /new (form) + /tools (net lib) + /admin (auth) + /live (WebSocket). import web:ext/web/web.mq.md import net:lib/net.mq.md import text:lib/text.mq.md import shell:styles/shell.mq.md import nav:components/nav.mq.md import side:components/side.mq.md import foot:components/foot.mq.md import articles:db/articles.mq.md import db:db/index.mq.md --- # main `home` = | 组件 | 样式 | |------|------| | nav.`nav` | shell.`topnav` | | side.`side` | shell.`side_panel` | | foot.`foot` | | `index` = | 属性 | 值 | 样式 | |------|-----|------| | title | articles.`articles`.title | shell.`card_title` | | body | articles.`articles`.body | shell.`card_body` | Home intro also embeds the live WebSocket widget (HTML is served raw). *store = > db.open* *page = > web.page title="Marqdo Net Site" intro="
Articles from SQLite, a live WebSocket widget, login-gated admin, and net-library parsing tools.
connecting…
"* *page = > page.compose_components components=home* *page = > page.compose_main main=index* About page: same shell. *about = > web.page title="About" intro="Demonstrates the network-extended web library: sessions, auth, WebSocket, multipart/cookie parsing.
"* *about = > about.compose_components components=home* Parse a `Cookie` request header with the standard library. *parsed_req = > net.cookie_parse text="session=abc123; theme=dark"* *req_cookie = parsed_req[^1]* Parse a `Set-Cookie` response header. *parsed_resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; SameSite=Lax" is_response=True* *resp_cookie = parsed_resp[^1]* Parse a `multipart/form-data` body. `_b` = net-boundary `_body` = "--`_b`\nContent-Disposition: form-data; name=\"title\"\n\nHello\n--`_b`\nContent-Disposition: form-data; name=\"cover\"; filename=\"pic.png\"\nContent-Type: image/png\n\nParsing demos powered by lib/net: cookie_parse and multipart_parse.
| | `req_cookie`[^name]=`req_cookie`[^value] | |
| | `resp_cookie`[^name]=`resp_cookie`[^value] · HttpOnly=`resp_cookie`[^http_only] | |
| | `mp_title`[^name]=`mp_title`[^value] | |
| | `mp_cover`[^name] · `mp_cover`[^filename] · `mp_cover`[^content_type] | |
Form inserts into articles.
"* *new = > new.compose_components components=home* *new = > new.compose_form id="article" form=article_form* Admin users table (english + chinese column headers both work). `admins` = | 行 | username | password | |----|----------|----------| | 1 | admin | secret | *app = > web.app page=page db=store admin=True host="127.0.0.1" port=18083* *app = > app.route path="/about" page=about* *app = > app.route path="/new" page=new* *app = > app.route path="/tools" page=tools* *app = > app.static dir="public" mount="/static"* *app = > app.route_ws path="/live" echo=True* *app = > app.auth users=`admins` session_ttl=3600* > `app`.listen