flask_reddit
flask_redditisaextedable+miimalistRedditcloe.
ThiswasbuiltsobegierswhowatastadardCRUD+reddit-likeapplicatiocaquicklygettowork.
Weutilize:
flaskasthewebframework.gixastheHTTPserverguicoasthewsgiserver.MySQLforourdatabaseflask-sqlalchemyasourORM.bootstrap-jouralthememakesusbeautiful.virtualevemcompasseseverythig.supervisordmakessureourserviceevercrashes.Adthatsprettymuchit!
Allofthecofigutatiosareithisrepository.Deploymetistructioswillbeoutsoo.
FeaturesthreadedcommetsupvotigsubredditsuserkarmasearchratelimitigajaxformpostiguserprofilesBuildIstructiosSetupaistaceofMySQLoyourserver.Noteyouruserameadpassword.sudoapt-getupdatesudoapt-getupgradesudoapt-getistallmysql-serverlibmysqlcliet-devSetupaistaceofgixoyourserver.I'veprovidedthe.cofscriptseededforourserversithe/serverdirectory.sudoapt-getistallgix
Cofigureyourgixsettigslocatediflask_reddit/server/gix.cof.
Addyoursettigsitoyourglobalcoffilelocatedi/etc/gix/gix.cof
Restartgixtorecogizeyoursettigssudoservicegixrestart
Setupsupervisordtomoitoryourprojecttomakesureitevercrashes.Supervisorisalsocoveietforsimplyrestartig/startigyourprojectwithease.
sudoapt-getistallsupervisor
WheSupervisorisistalledyoucagiveitprogramstostartadwatchbycreatigcofigfilesithe/etc/supervisor/cof.ddirectory.I'veprovidedthecoffilewhichweuseitherootdirectoryofthisrepoassupervisor.cof.AexamplesupervisorcommadwouldberuigsupervisorctlrestartYOUR_APP_NAMEtorestartguicoradbrigupewchages.
Istallvirtualevadsetupaprojectrootwhereeveryouwat.
sudoapt-getistallpytho-virtualev;cd/path/to/project;virtualevreddit-ev;cdreddit-ev;sourcebi/activate;#viola,youareowiaeclosedpythoworkspace.Dowloadtherepositoryadistallalloftherequiredpythomoduleswhichthisserveruses.gitcloehttps://github.com/codelucas/flask_reddit.git;cdflask_reddit;pipistall-rrequiremets.txtDuetosesitivecofiguratioiformatio,Ihavehiddemypersoalcofig.pyfileithegitigore.But,Ihaveprovidedacleaadeasytousecofigtemplateithisrepoamedapp_cofig.py.
Fillouttheflask_reddit/app_cofig.pyfilewithyourowiformatioadthereameittocofig.pysoflaskrecogizesitbyusigmvapp_cofig.pycofig.py.Pleasebesuretofilloutthemysqldbsettigssimilarlytohowyousetitup!,userame,pass,etc
Ruthekickstart.pyscripttobuildthefirstuseradsubreddits.
pytho2.7kickstart.py
flask_reddithastaskswhichmustoccuroregulartimeitervals.Tomakethishappe,weusethecrotab,whichispresetoUNIXsystems.Acrotabisadashwhichallowsyoutospecifywhatprogramstoruadhowofte.I'veprovidedflask_reddit'sexamplecrotabitherootdirectoryasjobs.cro.
Toviewyourcurretcrotab,rucrotab-l.Toedityourcrotab,rucrotab-e.
Pastethecotetsofjobs.croitoyourcrotabbyruigcrotab-eadpastig!Moredirectiosarepresetithejobs.crofile.
Rutheguicorserver.Youwo'thavetodothiseveragaiifsupervisorissetupproperly.
sudoshru_guicor.sh
Notethatwehaveowdeployedtwoservers:gixadguicor.gixisouriteretfacigHTTPserveroport80whileguicorisourwsgiserverwhichisservigupourflaskpythoapplicatiolocally.gixreadsclietrequestsaddecideswhichrequeststoforewardtoourguicorserver.Forexample,gixservesstaticcotetlikeimagesverywellbutitforwardsurlroutestothehomepagetoguicor.
Forafulllistofdetails,viewourcofigsatserver/gix.cofadserver/guicor_cofig.py.
Note,forthisbuildtoworktherearepathsthatyoumustchageithewsgi.pyfile,theservercofigslocatediserverdirectoryadtheru_guicor.shfile.
Refertotheflaskprojectcofiguratiooptiostouderstadwhattoputiyourowcofig.pyfile.
Doothesiatetocotactmeforhelporcocers.







评论