Flask, Express와 같은 웹 마이크로프레임워크인 Sinatra의 컨트리뷰터가 버전 2.0 로드맵을 공개하였다. 몇 가지 주요 변경점은 다음과 같다.
Ruby 2.2+ 와 Rack 2.0+ 이상을 지원한다.
rack-protection 과 sinatra-contrib 이 레포에 기본 포함된다.
mustermann이 기존 라우터를 대체한다.
seen from Hong Kong SAR China
seen from Türkiye
seen from China
seen from China

seen from Türkiye
seen from United Kingdom
seen from Netherlands

seen from United Kingdom

seen from United States
seen from United Kingdom

seen from United Kingdom
seen from Malaysia
seen from Türkiye
seen from Türkiye

seen from United Kingdom

seen from United States
seen from United Kingdom
seen from China

seen from Türkiye

seen from Türkiye
Flask, Express와 같은 웹 마이크로프레임워크인 Sinatra의 컨트리뷰터가 버전 2.0 로드맵을 공개하였다. 몇 가지 주요 변경점은 다음과 같다.
Ruby 2.2+ 와 Rack 2.0+ 이상을 지원한다.
rack-protection 과 sinatra-contrib 이 레포에 기본 포함된다.
mustermann이 기존 라우터를 대체한다.
PHP 프레임워크 Slim Framework 첫걸음
안녕하세요. 먼데이치킨의 Selen입니다.
저는 지금 Slim을 통해 API서버를 만들어보려고 하는데요,
일단 서버의 상황을 적자면 AWS에 있는 EC2 t2.nano 인스턴스입니다. 도메인을 A레코드로 연결해놓았고, EIP를 사용중입니다.(도메인 연결하려면 당연한건가요?
DB는 RDS로, mariaDB를 사용해 테스트할거에요.
지금 이 글을 적는 시점은 2016년 3월 3일. 3월 초입니다.
이때의 버전은 3.1이었지만 회사에서 일하고 있는 사이에 또 새로운 버전이 나왔네요. 슬림은 버전이 너무 빨리바뀌는것 같아요. 일단 이대로 가봅니다.
이제 대충 상황설명이 끝났으니 슬림을 사용해보려고 하는데요, 일단 저는 서버에 PHP7를 설치하고, 컴포저를 설치했습니다. 그리고 Slim Framework의 공식 사이트에 나온대로
composer create-project slim/slim-skeleton 프로젝트이름
위와 같은 커맨드를 통해 새 프로젝트를 생성했습니다. 물론 커맨드를 실행했던 위치는 API가 있어야 할 위치로 했지요! 그러면 시간이 지나더니 이것저것 설치가 됩니다.
Slim 실행
이제 저는 한번 실행해보기로 합니다.
그 전에 해당 프로젝트의 권한을 모두 755로 바꿀건데요, 제가 무지한 관계로(...) 이게 해도 되는건지, 나쁘지 않은것인지 정확하게 알지 못합니다. (제게 현명한 방법을 알려주실분을 찾습니다.)
일단 해봅니다.
sudo chmod -R 755 프로젝트이름
위와 같이 했습니다. 그리고 나서 이 다음 역시 홈페이지 메인에 나온대로 따라할건데요,
cd 프로젝트이름
php -S 0.0.0.0:8080 -t public public/index.php
이렇게 따라해봅니다. 그리고 나서 API서버의 주소에 8080포트를 붙여서 접속해봅니다. 잘되요. 아주아주 만족스럽게 이쁘게 나와줘서 고맙네요.
8080포트를 80 또는 443으로 바꿔보고 싶지만 그건 나중에 해볼래요.
일단 route를 다뤄보고 싶어요. 왜냐면 뭐든 연결이 되어서 결과값이 눈에 보여야 잘 알수있잖아요!
그러므로
프로젝트경로/src/routes.php
파일을 들여다 보게되면 라우팅 관련 설정들이 있어요! 지금은 뭔가가 적혀있지만 저는 제가 알아볼수 있는것만 써볼거에요.
기존에 적혀있던 소스를 아주아주 조금만 바꿔서 작동하는지 확인해 볼건데요, 저는 아래처럼 해봤어요
$app->get('/test', function ($request, $response, $args) {
$this->logger->info("Slim-Skeleton '/' route"); // 아마 로그를 남기는 친구겠죠.
return $this->renderer->render($response, 'index.phtml', $args);
});
Bold처리된 부분만 바꿔보았는데요, logger는 로그를 남기는 함수들이 있는것같아요. 그리고 renderer도 말 그대로 렌더링할때 도움을 주는 함수가 있는 친구가 아닐까 싶어요.
그리고 return값은 아마 템플릿파일을 불러와서 php파일을 적당히 처리해주겠죠? 자세한건 저한테도 묻지마요..(자세히 아시는분은 말해주시면 되요!! 환영)
그리고 전 라우팅을 여러개 하는 방법이 단순하게 추가하기만 하면 되는건지 궁금해서 시도해 볼거에요.
신난다! 역시 되는군요
$app->get('/member/login/{id}/{passwd}', function ($request, $response, $args) {
$this->logger->info(”TEST '/member/login' route");
print_r($args);
});
print_r함수를 쓰거나 echo로 보여줘도 잘 나오더라고요. 그래서 $args변수에 뭐가있는지 궁금해서 확인해보느라 저렇게 바꿔보았어요.. ($request랑 $respone도 확인해봤지만요)
파라메터에 []을 감싸면 옵션으로 받을수 있는건줄 알았는데 그건 딱히 아닌가봐요...... 슬프다..
그런데! 제가 잘못했던것이었어요!
저는
$app->get('/member/login/[{id}]/[{passwd}]', function ($request, $response, $args) {
$this->logger->info("Bacving-API '/member/login' route");
print_r($args);
});
와 같이 id, passwd 둘다 옵션으로 받으려고 했었지만 사실은 맨 뒤의 인자값만 옵션으로 가능한것 같아요.
$app->get('/member/login/{id}/[{passwd}]', function ($request, $response, $args) {
$this->logger->info("Bacving-API '/member/login' route");
print_r($args);
});
처럼 하니까 아주 잘 되더군요.
아무래도 로그인 방식은 이게 맞지 않은가 싶어요. 우선적으로 RESTful에 대해 정확히 알아보고 와야겠어요.
일단 라우팅을 아주아주 약간만 다뤄보았어요.
이것만 해도 json형식으로 넘겨주기 아주 딱 좋은 난이도네요.
그럼 RESTful에 대해 알아보고 다시 만나요!
Lightning Fast, Super Simple web framework for Crystal. Inspired by Sinatra
Ruby와 비슷한 간결한 신택스를 가졌지만 정적으로 컴파일되는 언어인 Crystal을 위한 웹 마이크로프레임워크. Ruby의 Sinatra나 Python의 Flask와 비슷.
A sip from Flask
Lately I came to find Django a bit top heavy for one of my projects, so I chose Flask as a lighter and smaller alternative. After fiddling with the tutorials for a bit I wanted to have a setup with several modules. Suprisingly that wasn't as easy to do as the snippets and examples showed several options and configurations and... So, this is what worked for me. May not be the true gospel but I wanted modules to be set to certain urls like mounted apps in padrino.
This is what I came up with:
+ Project -- start.py + module1 -- __init__.py -- app.py + module2 -- __init__.py -- app.py
So module1 and 2 are two functional units which should answer to specific prefixes (localhost:5000/module1 and localhost:5000/module2) and start.py is the file to run the whole show.
I used flask-blueprint to get it all under the roof.
First let's get the modules to behave like modules. In module1/app.py I added:
from flask import Blueprint app1 = Blueprint('app1', __name__) ... @app1.route ...
For module2 app.py looks similar except that app1 is changed to app2.
So, now we have the blueprints, of which the project does not know yet. In fact we don't have any app so far. All the nutrs and bolts go into start.py:
from flask import Flask from module1.app import app1 from module2.app import app2 project = Flask(__name__) project.register_blueprint(app1, url_prefix='/path1') project.register_blueprint(app2. url_prefix='/path2') if __name__ == '__main__': project.run()
This is the beauty of blueprint (imho). Import the blueprint, register it and pu t it on a dedicated path.
Done. To modules in a flask-application.
New project!
I've been in the design and plan out stage for a new project for a couple of weeks now, and I am REALLY excited about it. It is going to be an image board website / application for storing and managing images.
I know there are tons of these but none of them really do it exactly like I want. The one that gets the closest only allows anime images. They have the source code provided, however it's written with some weird stuff set up basically with only Debian in mind, and even on a modern Debian system I could barely get it running. I hate Debian, so I tried getting it running on both Gentoo and Cent OS with no luck.
So screw that, I'm just going to write my own.
It will be written in Python on the Flask microframework. If it ever goes public, it will likely live on Heroku for the app and PostgreSQL Database and Amazon S3 for image storage, assuming pricing for Heroku doesn't kill me.
The main purpose is that I have an art collection on my computer comprising of over 25K images that I've been collecting for many years. Unfortunately they are very unorganized and lack all sources. A tagging system is perfect for organization, but I haven't found any good apps for such a thing.
What's cool, this sounds like it may be a great alternative to something like imgur or flicker, or even a product that I can license out to photographers to showcase their photography. Honestly there are quite a few opportunities to turn this into a business, so I'm excited.
So when something you want doesn't exist, build it yourself.
.NET Micro Framwork and Visual Studio 2013
For those of you that have been following my blog you know that I have a love for the AGENT SmartWatch. I have been working on apps for it as well as a "port" of MonoGame for it.
Recently I reinstalled Windows 8.1 as a completely fresh install. I decided that I would use this to finally switch from Visual Studio 2012 to 2013. While I'm loving 2013 so far I ran into one problem. The most recent .NET Micro Framework installer is only for 2012. Since the AGENT SmartWatch uses the .NET Micro Framework as it's "platform" without it I could not do any development. Being a nerd and a geek I couldn't accept this and decided that I'd try to make it work. Luckily I did and hopefully this will work for you too.
Before we can get to the fun "hacking" part, first some disclaimers. What I am doing is NOT supported by Microsoft, Secret Labs, the .NET Micro Framework team, the Visual Studio team, or myself. If something breaks from following the instruction I'm giving you can comment, but I not obligated to and may not have an answer. As a follow up to that following the instructions CAN break stuff, even if followed exactly. Also please not that this fix DOES NOT add the new project templates correctly. If you are ok with all that then please continue on reading and let the fun begin.
First problem was that the installer would do a check for Visual Studio 2012 and if it was not installed would throw an error message and not run. Luckily the .NET Micro Framework is open source, including the installer. After looking through the files I eventually came across the file that contains the logic for detecting Visual Studio 2012. All it does is look for the "InstallDir" value in the "HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\" key (on 64 bit systems it looks in "HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\"). If it finds the value it assumes 2012 is installed, otherwise it assumes it is not. Solving this issues is as simple as just creating the key and value. The "InstallDir" value is a string value that points to the Install directory of that version of Visual Studio. Since we are trying to trick the installer set the value as the location of Visual Studio 2013.
Now you can run the .NET Micro Framework installer. File wise everything works correctly since it uses the location from the registry to put files in Visual Studio that it needs to. unfortunately the same cannot be said of the registry, though it is fairly easy to fix.
Navigate back to "HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\" key (on 64 bit systems "HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\"). Under the "11.0" key you will notice a lot of keys and values. What you need to do is find the keys that are for the .NET Micro Framework integration and copy them to the "12.0" key (the numbers 11.0 and 12.0 are the internal version numbers of 2012 and 2013 respectively). If you use RegEdit like there is sadly no copy ability. A trick I used to overcome that was to export the key I wanted to copy to a .REG file. Once it was exported I would edit the file, which is really just a simple text file. I would replace all the references to "11.0" with "12.0", save the file, and then open it.
Once you've moved them all there is only one step left. While we have set everything up correctly, we need to tell Visual Studio to "load" the changes. To do this you simply run Visual Studio with the "setup" flag. On my machine that looked like
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /setup
It may take a while to run so keep an eye on it from Task Manager. Once it finishes though you should be able to open existing .NET Micro Framework projects.
MonoGame on the AGENT Watch
In what can only be called an insane move I've decided to try porting MonoGame to the AGENT Watch. In a net shell the AGENT Watch is a watch that runs the .NET Micro Framework (the smallest version of the .NET Frameworks designed to run on hardware WITHOUT an Operating System) allowing for custom "watch faces" as well as apps.
Why would I do this? After all I doubt there are going to really be any need for cross platform game development with a watch ;)
It's an excuse to learn more about how MonoGame works on the inside.
On the topic of how it works because the watch uses the Micro Framework a lot of things we take for granted in .NET/Mono like string.Format and List<T> aren't there. Therefore I need to learn how these things work so I can build them.
I've wondered for a while if MonoGame could be adapted to draw to a System.Drawing.Bitmap and what do you know that's what you draw to on the watch to draw to the screen!
To tackle this my first goal is to deal with the problem I mentioned in #2. Currently for a lot of things I'm looking to Mono actually for how to do it, though in many cases I can't uses things exactly as are and have to adapt them (for instance I can't add Format back to the string class. Best I can do is make my own String class and use #ifdef to switch calls from string.Format to myString.Format).
I won't be porting MonoGame perfectly though (at least at first). These limits are both based on limits of the watch and time I have:
No 3D stuff, only 2D.
No Media. That means no Songs, Sounds, or Video
No Networking. While the watch includes Bluetooth to communicate with a phone because that works so differently than the networking APIs in MonoGame for now I'm leaving it out.
Currently I'm fighting my way through making LINQ work in the Micro Framework, though if it fails enough I might just give up and manually remove LINQ usage.
Update:
Tom Spilman pointed out to me on GitHub that the .NET Micro Framework does not support Generics which I had incorrectly thought it did. Sadly this will put this port way behind but I'll still keep at it!
Windows Phone 7.1 + MicroFramework and Tiles alarm (by push notification)