user-input

Python - User input to CGI via. Threading and reading file

橙三吉。 提交于 2019-12-06 00:06:28
Look at the bottom of this post, for final working code. It's a working Python/CGI script which can get user-input to a CGI-script by calling another script which then sends it's commands through a local socket. Original post: As far as I know, there isn't any way to send user input directly to a Python/CGI script which has allready sent it's header. Like, warning the user under specific circumstances and waiting for a confirmation. Neither have I been able to find any published solutions to this. If I'm wrong, please correct me. I currently have a Python script which can connect to servers,

prompt for user input when running scala program with sbt

五迷三道 提交于 2019-12-05 23:25:27
问题 I have a very simple scala program: object TakeInputs { def main(args: Array[String]) { val name = readLine("What is your name?") println(name) } } When I try to run this with sbt "project myproject" "run-main TakeInput" it doesn't wait for user input and the program just finishes with What is your name?null as the output. Is there a way to make sbt wait for user input (like what happens if "readLine" is run in sbt console)? I can provide the inputs as command line parameters but I have a lot

What is the correct way to make web form input safe for a variety of contexts?

拟墨画扇 提交于 2019-12-05 22:01:49
问题 What do you all think is the correct (read: most flexible, loosely coupled, most robust, etc.) way to make user input from the web safe for use in various parts of a web application? Obviously we can just use the respective sanitization functions for each context (database, display on screen, save on disk, etc.), but is there some general "pattern" for handling unsafe data and making it safe? Is there an established way to enforce treating it as unsafe unless it is properly made safe? 回答1:

How can I read multiple lines of user input in AutoHotkey?

我的未来我决定 提交于 2019-12-05 20:22:24
I have an AutoHotkey script which needs to read multiple lines of employee data from a user. InputBox, userInput, Employee Records, Please enter employee records. (One per line) Unfortunately, an InputBox only allows users to enter a single line of text. Trying to add newlines with Enter will instead submit whatever data has been entered. How can I take in multiple lines of user input in an AutoHotkey script? This implements a generic multiline input function F3::MsgBox % MultiLineInput( "Employee Records", "Please enter employee records (One per line):" ) MultiLineInput(title, prompt) {

Safely executing user-submitted python code on the server

心不动则不痛 提交于 2019-12-05 19:38:52
问题 I am looking into starting a project which involves executing python code that the user enters via a HTML form. I know this can be potentially lethal ( exec ), but I have seen it done successfully in at least one instance. I sent an email off to the developers of the Python Challenge and I was told they are using a solution they came up with themselves, and they only let on that they are using "security features provided by the operating system" and that "the operating system [Linux] provides

Python excepting input only if in range

≡放荡痞女 提交于 2019-12-05 13:35:30
Hi I want to get a number from user and only except input within a certain range. The below appears to work but I am a noob and thought whilst it works there is no doubt a more elegant example... just trying not to fall into bad habits! One thing I have noticed is when I run the program CTL+C will not break me out of the loop and raises the exception instead. while True: try: input = int(raw_input('Pick a number in range 1-10 >>> ')) # Check if input is in range if input in range(1,10): break else: print 'Out of range. Try again' except: print ("That's not a number") All help greatly

how to catch blank input with scanner class in java

断了今生、忘了曾经 提交于 2019-12-05 13:22:10
I am using the scanner class to capture user input from the command line (strings only), as an alternative to my previous question . The following seems to work fine, except the blank lines are not caught as they should by the second conditional. For example when I press enter, this should be captured as a blank line and the second conditional should be true. However a new blank line is displayed on the console everytime, with the entire console "scrolling" upward if I keep hitting enter, rather than the logic in the conditional. Is there a proper way to catch a blank input from the command

Java Scanner does not wait for input

喜欢而已 提交于 2019-12-05 12:56:34
I have two blocks of code here. One scanner properly waits user input, and the other just blows right through it and calls nextInt() which returns a NoSuchElementException . Here is the block that works: public void startGame() { out.println("Player1: 1 for dumb player, 2 for smart player, 3 for human player."); Scanner scan = new Scanner(System.in); p = scan.nextInt(); if (p == 1) p1 = new DumbPlayer("ONE"); if (p == 2) p1 = new SmartPlayer("ONE"); else p1 = new HumanPlayer("ONE"); out.println("Player2: 1 for dumb player, 2 for smart player, 3 for human player."); p = scan.nextInt(); if (p ==

Best way to check whether a TextBox is empty or not

为君一笑 提交于 2019-12-05 10:49:05
I have a TextBox. And I want to check if it's empty. Which way is better if(TextBox.Text.Length == 0) or if(TextBox.Text == '') ? You should use String.IsNullOrEmpty() to make sure it is neither empty nor null (somehow): if (String.IsNullOrEmpty(textBox1.Text)) { // Do something... } More examples here . For practical purposes you might also consider using String.IsNullOrWhitespace() since a TextBox expecting whitespace as input probably negates any purpose, except in case of, say, letting the user pick a custom separator for stuff. I think string.IsNullOrEmpty(TextBox.Text) or string

jQuery: password field with readable label?

两盒软妹~` 提交于 2019-12-05 09:27:17
问题 I wrote this very simple function for my current project called insidelabel() that let's me add a description (label) for an input field inside of the input. //Label inside of inputfields function insidelabel(selector, name) { $(selector).val(name); $(selector).css({'color':'#999'}); $(selector).focus(function () { //Input Value if ($(this).val() == name) { $(this).val(''); } $(this).css({'color':'#000'}) }); $(selector).blur(function () { if ($(this).val() == '') { $(this).val(name); } if ($