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
8
votes
1 answer

How to receive uploaded file with Klein like Flask in python

When setting up a Flask server, we can try to receive the file user uploaded by imagefile = flask.request.files['imagefile'] filename_ = str(datetime.datetime.now()).replace(' ', '_') + \ werkzeug.secure_filename(imagefile.filename) filename =…
JLTChiu
  • 983
  • 3
  • 12
  • 28
7
votes
2 answers

How to execute code asynchronously in Twisted Klein?

I have two functions in my python Twisted Klein web service: @inlineCallbacks def logging(data): ofile = open("file", "w") ofile.write(data) yield os.system("command to upload the written…
JLTChiu
  • 983
  • 3
  • 12
  • 28
5
votes
1 answer

Access json content of http post request with Klein in python

I have a simple http client in python that send the http post request like this: import json import urllib2 from collections import defaultdict as dd data = dd(str) req = urllib2.Request('http://myendpoint/test') data["Input"] = "Hello…
JLTChiu
  • 983
  • 3
  • 12
  • 28
3
votes
1 answer

How to use multiple core with a webservice based on Python Klein

I am writing a web service based on Klein framework https://klein.readthedocs.io/en/latest/index.html At this stage I am stress testing my service, it can handles about 70 requests per second on amazon t2.medium instance. But when I use top to …
JLTChiu
  • 983
  • 3
  • 12
  • 28
2
votes
1 answer

PHP klein router call special controller function

I'm implementing the Klein router in php and I have a little problem... I would like to call a special function from my controller, giving it (or not) $request variable like this : $klein->respond('GET', '/[i:id]?',…
Simon Trichereau
  • 721
  • 11
  • 19
2
votes
1 answer

Twisted Klein: Synchronous behavior

I am using Twisted Klein because one of the promise of the framework is it is Asynchronous, but i tested that app i develop and a little code for testing and the framework behavior seems to be synchronous. The test server code is: # -*- encoding:…
2
votes
1 answer

How to send out two request at the same time with python

So I was following a guide at http://tavendo.com/blog/post/going-asynchronous-from-flask-to-twisted-klein/ to create an asynchronous web service. in my code, I had a function that will send out the request like def query(text): resp = yield…
JLTChiu
  • 983
  • 3
  • 12
  • 28
2
votes
1 answer

Is it possible to pass in an existing socket for Twisted to listen on?

I'm building some Twisted/Klein services for some command-line tools I am writing and I would like to use systemd's socket units. To do that, I would need to accept the socket via a file descriptor when the application starts and pass that socket to…
Deven Phillips
  • 1,129
  • 14
  • 39
2
votes
1 answer

Klein url router not working on XAMPP

My app is on C:\xampp\htdocs\urlrouter\klein\ I installed the klein router using composer. And, I use this script just for simple basic routing define('APP_PATH', '/urlrouter/klein/'); require_once 'vendor/autoload.php'; $request =…
Terry Djony
  • 1,975
  • 4
  • 23
  • 41
2
votes
2 answers

Using klein.php without composer?

Is there any code example? Here's what I got: // index.php require_once __DIR__ . '/Klein/Klein.php'; $klein = new \Klein\Klein(); $klein->respond(function () { return 'All the things'; }); On PHP 5.3 this returns an error (Fatal error:…
Antwerp
  • 47
  • 1
  • 8
2
votes
1 answer

PHP routing: display flash messages in View (Klein)

I am using Klein php routing for a simple app the documentation is ok for using the library, however it is not good at how to implement the views for instance I want to display a flash message on success/error/warning etc i understand how klein can…
Jay Rizzi
  • 4,196
  • 5
  • 42
  • 71
2
votes
1 answer

$_POST with klein.php router: How to pass $_POST to a view?

Fishing in uncharted waters, I gave klein.php routing a spin and can't for the life of me find out how to pass a $_POST from a html form to another view. Example: index.php
David K.
  • 324
  • 1
  • 7
  • 20
1
vote
1 answer

Google App Engine Application - 502 bad gateway error with klein micro web framework

I developed an python webcrawler application based on scrapy and packaged it as a klein application (klein framework) When I test it locally it everything works as expected, however when I deploy it to google app engine I get a "502 bad gateway". I…
1
vote
1 answer

Python Klein - Non Blocking API

Need help with Klein API for Non-blocking. This is a simple test app: # -*- coding: utf-8 -*- import datetime import json import time from klein import Klein app = Klein() async def delay(seconds): """Set some delay for test""" …
1
vote
1 answer

How to test Klein server in python

I have made an async http api in Python using Klein. I would like to test my requests using something like Unittest or similar. I have found this but I'm not sure I'll be able to implement it remotely the same way. Is there a correct and direct…
1
2 3