This represents a proof of concept, minimal web stack. I used http://nicolasmerouze.com/build-web-framework-golang/ series of articles as a starting point and the goal was to keep the stack as minimal as possible while still being useful for practical purposes. And of course, use the standard library as much as possible and only integrate components compatible with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * $Id: simple-tcp-proxy.c,v 1.6 2002/11/27 00:40:31 wessels Exp $ | |
| */ | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <stdlib.h> | |
| #include <errno.h> | |
| #include <netdb.h> | |
| #include <string.h> | |
| #include <signal.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --[[ | |
| LuaJIT-cURL | |
| Lucien Greathouse | |
| LuaJIT FFI cURL binding aimed at cURL version 7.38.0. | |
| Copyright (c) 2014 lucien Greathouse | |
| This software is provided 'as-is', without any express | |
| or implied warranty. In no event will the authors be held | |
| liable for any damages arising from the use of this software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Markdown Third Party | |
| ============================ | |
| This plugin allows you to use various third-party | |
| Markdown extensions to make writing posts in Markdown | |
| easier and better. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from gevent import monkey | |
| monkey.patch_all() | |
| monkey.patch_sys(stdin=True, stdout=False, stderr=False) | |
| import gevent | |
| from gevent.queue import Queue | |
| import signal | |
| import sys | |
| from socketio.namespace import BaseNamespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import hiredis | |
| d = {} | |
| def process(req): | |
| cmd = req[0].lower() | |
| if cmd==b'set': | |
| d[req[1]] = req[2] | |
| return b"+OK\r\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import requests | |
| def fetch_page(url, idx): | |
| #loop = asyncio.get_event_loop() | |
| url = 'https://bing.com' | |
| future = loop.run_in_executor(None, requests.get, 'http://www.bing.com') | |
| response = yield from future | |
| if response.status_code == 200: | |
| print("data fetched successfully for: %d" % idx) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/base64" | |
| "net/http" | |
| "strings" | |
| ) | |
| type handler func(w http.ResponseWriter, r *http.Request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: uwsgi-emperor | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the uwsgi emperor app server | |
| # Description: starts uwsgi app server using start-stop-daemon |