Questions tagged [klein-mvc]

Klein is a web micro-framework used to develop web services with Python. Use this tag for questions pertaining to issues with Klein-MVC.

Klein is a micro-framework for developing production-ready web services with Python. It is 'micro' in that it has an incredibly small API similar to Bottle and Flask. It is not 'micro' in that it depends on things outside the standard library. This is primarily because it is built on widely used and well-tested components like Werkzeug and Twisted.

35 questions
1
vote
2 answers

Python shell working differently on different location in the same machine inside same virtual environment

I have a cloud instance of a Linux machine (openSuSE) with multiple users. I have created a virtual environment and installed all my required libraries (including Klein). I have two users "a" and "b". While logged in as "a" and inside virtualenv,…
1
vote
1 answer

twistd -n web not working with Klein and Python3

i'm try to run twistd web with Klein and got a lot of issues. Even if try run it from an example - got the same results. Source from klein import Klein app = Klein() @app.route('/') def hello(request): return "Hello, world!" resource =…
1
vote
0 answers

Http POST request in python using Klein for accessing json content

I needed to POST a dictionary using Klein from klein import Klein import json app = Klein() dictionaries=[] @app.route('/dict',methods=['POST']) @inlineCallbacks def pg_root(): dictionary = {'key'…
Sana Hameed
  • 81
  • 1
  • 5
1
vote
1 answer

Starting python Klein using twistd throws no module Error

Hi, I am trying to start a Klein server using twistd method. I tried it by reading the Klein documentation. But when I tried to start the server, it says no module found. Here is the sample code of what i tried, helloworld.py : from klein import…
Karthikeyan KR
  • 1,134
  • 1
  • 17
  • 38
1
vote
1 answer

Redirect if page != login or register? Klein

today I have a question about Klein and I am asking becasue there isn't much documentation on this library on the internet. I want to redirect the user back to /login if they are on any page other than "/login" or "/register" AND they arent logged…
Stuart Little
  • 33
  • 1
  • 4
1
vote
2 answers

klein script CSS isn't working

I have a very simple klein script that is just a reverse-proxy: from klein import run, route, Klein from twisted.web.proxy import ReverseProxyResource @route('/') def home(request, branch=True): return ReverseProxyResource('www.example.com',…
Cristian
  • 495
  • 2
  • 9
  • 35
1
vote
1 answer

How do I run Klein with twisted?

I'm trying to run klein with twisted, so I can run twisted scripts on different paths (exp: example.com/example1, example.com/example2). So I made a simple script: from klein import run, route, Klein from twisted.internet import reactor from…
Cristian
  • 495
  • 2
  • 9
  • 35
1
vote
1 answer

onHttpError in klein.php executes every time

I'm using klein.php router, which is really powerful, But Now I want to handle exceptions, so from the documentations I'm using this function $klein->onHttpError(function ($code, $router,$matched,$method_matched,$http_exception) { switch ($code) { …
user3515181
  • 49
  • 1
  • 8
1
vote
2 answers

How to serve static files using Klein.php

I'm trying to serve static files located in /web directory using Klein.php like this : $klein->respond('/web/[*]', function($request, $response, $service, $app) { return $service->file(__DIR__ . $request->pathname()); }); But receive this error…
Youssef Bouhjira
  • 1,599
  • 2
  • 22
  • 38
0
votes
0 answers

Is there a way to add user sessions to twisted/klein web framework?

I used the twisted/klein micro framework to build a small web app. I would now like to add a part to the app which is password protected. Is there a way to do that? It seems like twisted has a way to do it, but I cannot figure out how to roll it…
Lucas
  • 13,679
  • 13
  • 62
  • 94
0
votes
0 answers

Gunicorn python Klein

Use Klein for the server and want to run it via Gunicorn. from klein import Klein app = Klein() @app.route('/') def hello(request): return "Hello, world!" resource = app.resource Working good in twistd -n web --class=twistdPlugin.resource but…
0
votes
1 answer

Python Klein - How to return Excel file as attachment?

i'm use Python Klein for my small API. Can return csv as response, but is this possible to return Excel file? Flask has this functional but what about Klein? Task: Have Excel file on hard drive and want return it to as attachment, so user can…
0
votes
0 answers

Implementation of long-polling in asynchronous web framework like twisted or klein

I'm relatively new to REST API and web development in general. I'm looking for options for a client GET request to receive data incrementally/streaming until all data is sent with some criterias: Has to be async (need to use twisted/klein as…
Ardhi
  • 2,855
  • 1
  • 22
  • 31
0
votes
1 answer

Conda package for Klein (Twisted micro web framework)

Is there a conda channel that contains "klein" package? http://klein.readthedocs.io/en/latest/
victtim
  • 790
  • 5
  • 17
0
votes
2 answers

Process Multiple Requests Simultaneously and return the result using Klein Module Python

Hi I am using Klein Python module for my web server. I need to run each request separately as a thread and also need to return the result. But Klein waits until the completion of single request to process another request. I also tried using…
Karthikeyan KR
  • 1,134
  • 1
  • 17
  • 38