Quick Navigation All projects Hardware Links Top projects Alan numitron clock Clapclap 2313/1386 SNES Pi Webserver USB Volume/USB toys Smokey amp Laser cutter WordClock ardReveil v3 SNES Arcade cabinet Game boy projects cameleon Home Presence Detector GitHub AlanFromJapan Contact me Who's Alan? Akizukidenshi Elec-lab Rand Nerd Tut EEVblog SpritesMods AvrFreaks Gameboy Dev FLOZz' blog Switch-science Sparkfun Suzusho Datasheet Lib Reddit Elec Ermicro Carnet du maker (fr) |
SNES Pi webserverLast update: Tue Nov 28 13:28:49 2023
PurposeNeed a web server for self hosting, use a Raspberry Pi 2 of course (seeing I expect 200-300 page views a day we're safe). I need a DMZ in my internal network so the old router sleeping in the closet found a new life. I also had those beefy AC/DC modules in my lucky bag in Akihabara years ago, make the 110v a steady 10.5V with a decent amount of amps (measured 4 when short cutting I think). Throw in a couple of step down "buck" converters (no 7805) from eBay to have a decent efficiency and get my 5v for the Raspi as 3.3v for the router. Interresting fact this SoB of router does not work with 3.3v but is fed about 3.5-3.6v otherwise it doesn't start or keep rebooting. Not the fault of the power module, I tested with my beefy DC supply and with a precise 3.3v it keep on rebooting. The original power plug was measured 3.47V (though labelled 3.3v), so, what the hell, it works, maybe not for a century but I'll manage.The whole thing is stuffed inside a SNES body that was the empty shell of my Arcade cabinet made with a SNES. I had to make fake joypad port, just wood with a few holes and painted/varnished the same as the SNES original grey, ... if you don't pay attention it makes acceptable illusion. Bill of materials
Pictures
SoftwareNow comes the fun. My goals are to:
Option 1 use a home made Python webserver✗ Which is what I did first, it handled bravely a few attacks until some a$$hole found a breach and killed it with a few commands. Yeah, BaseHTTPServer is not the most robust implementation.Option 2 a existing Python framework✔ Flask is the answer. and that's the way to go!I used the Flask to build a custom single editor multithreaded webservice. I can edit pages on the site live, that works quite fine. It's a work in progress, but if you're interrested do check on github, there's the full site: https://github.com/AlanFromJapan/alanWebSites Option 3 a fullfledge web server✗ Not Apache (robust but cabalistic config), but maybe an easier/lighter Nginx? Would have worked but I wanted some flexibility.InstallationI put it here for memory, since when I make update I work on other servers now (all the content is on Github so why not?).The site executes under Python 2.7+:
You need flask as the main engine, and you need futures for multithreading thread-pool for blinking leds. The above commands get you easy_install to get pip to get the before mentionned packages.Now to get the site source : git clone https://github.com/AlanFromJapan/alanWebSites.git and go get a small coffee.Once downloaded, edit the electrogeek.ini file and run by python electrogeek_flask.py or use the start script.Notes regarding the Leds: adding the leds support came with a few tricks (and thanks to this person for sharing): sudo rpi-update and the usual apt-get update/upgradesudo adduser webuser gpio sudo chown root.gpio /dev/gpiomem ; sudo chmod g+rw /dev/gpiomem UpgradesShutdown buttonIt's documented on the Raspi GPIO fun page, just check. Now there's a kill button hidden behind the cartridge.Page served LEDFollowing the code change in the present project source code, check theledz.pi thing and documented here, each time a page is served a small green led blinks. It's next to the red power led.
NetworkTopologyI won't go into micro details here because it will change between your house and me, and it gets a little too private. I'm no network expert, so forgive if some details I keep before me.Dashed lines are wifi, plain are wired, red is DMZ (as setup in the main router) and blue is regular intranet SecurityOn the main router: |
||||||
All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated) electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2024]) |