Flask- Cannot read or write to file - amazon-ec2

I am using AWS EC2 to host a Flask application and I am trying to read and write to a text file when the user submits a form using the open() function. When the form is submitted I am getting the error:
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
I am not sure why this error is happening.
The code that does this is:
#app.route("/submit", methods=["POST"])
def submit():
file = open("settingsfile.txt", "w")
file.close()

Related

Laravel file put contents failed to open stream operation not supported

This project run well in xampp but when move it to ubuntu apache2, I get this error message. Is not a permission problem. If I put the dd helper at end blade file, it load the page correctly.
ErrorException
file_put_contents(/run/user/1000/gvfs/smb-share:server=cabrita-virtualbox.local,share=site/galeria/storage/framework/sessions/3RXOohAHEL8WhCloIrnEzP9VsAgjRF2CFtwVcDKA): failed to open stream: Operation not supported
http://127.0.0.1:8000/
image_error

Can't establish connection to Web Server using rosbridge

I have created a simple HTML page to control the movement of a simulated Gazebo Turtlebot using roslaunch rosbridge_server rosbridge_websocket.launch following this tutorial.
However, in the Web Console of the HTML page (F12) it shows the error "Firefox cant establish a connection to the server at ws://localhost:9090/." I am using the default rosbridge for the websocket(9090). In the Terminal I am also receiving the errors:
[-] failing WebSocket opening handshake ('WebSocket connection denied: origin 'null' not allowed')
[-] dropping connection to peer tcp4:127.0.0.1:41290 with abort=False: WebSocket connection denied: origin 'null' not allowed.
Does anyone have any suggestions on how I can fix this?
Given that you have followed the ROS tutorial and have created an HTML file as shown in Ros Bridge tutorial then you have to run:
runcore
rosrun rospy_tutorials add_two_ints_server
roslaunch rosbridge_server rosbridge_websocket.launch
Now that you have these up and running, you need to serve the html/javascript file (e.g. simple.html) and start the services etc. For example, you can serve the simple.html by using a SimpleHTTPServer, see below an example (e.g. simplehttpserver_test.py):
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.path = '/simple.html'
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Handler = MyRequestHandler
server = SocketServer.TCPServer(('127.0.0.1', 9089), Handler)
server.serve_forever()
Once you run the simplehttpserver_test.py you can open the browser on 127.0.0.1:9089 and you should be able to have it working.
Note that SimpleHTTPServer serves files from the current directory and below, directly mapping the directory structure to HTTP requests, which means that the simple.html should be in the same (or below) directory as the simplehttpserver_test.py. Last, the port for the simplehttpserver_test.py should differ from the one used for the Rosbridge WebSocket server (e.g. default is 9090).

How to read grpc command line tool error messages from the responses?

I am using the grpc command line tool to test response for my grpc request. This is the official link to the grpc command line tool: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md (The usage guide is not updated. Kindly read ~/workspace/src/github.com/grpc/bins/opt/grpc_cli help)
I am running the command from the location where my protocol file resides. I am sending a request like this, (FYI: I am also sending the metadata. Irrespective of inclusion of the metadata or not I am getting the same error message) :
$ ~/my_workspace/src/github.com/grpc/bins/opt/grpc_cli call 0.0.0.0:50051 \
MyGrpcMethod <name_of_my_proto_file.proto> "abc : '12-34-56-78', xyz: '1234'" \
--metadata "auth:<auth_token>:space:xxx:org:xxx" --enable_ssl=false
In the response I am getting it says that there are some errors however, it does not show what the errors are. Here is the response I got from my client request:
connecting to 0.0.0.0:50051
Failed to read response.
Rpc failed with status code 12 error message unknown service my_agent.MyServiceAPI
Right now, I am not able to figure out from the documentation or otherwise on how to read the response. Did anyone face an issue like this?

PhantomJS failing on remote ajax field check

I developed a script to complete & submit a remote form via PhantomJS (version 2.1). For testing I built a local approximation of the remote form which included an ajax field check upon input (so, you enter an email address in the email field, and after a second it checks to see if it's a valid input). My phantom script fills out the fields, waits a few seconds for an error to be thrown, and then carries on to submit the form if everything looks okay. This all worked just fine with everything running on localhost.
However, as soon as I switch to making the call to the remote webpage (which is a third-party site; I have no access to make changes to it), it fails when the remote page performs the ajax check on fields. I have the following onResourceError function:
page.onResourceError = function(resourceError) {
system.stderr.writeLine('= onResourceError()');
system.stderr.writeLine(' - unable to load url: "' + resourceError.url + '"');
system.stderr.writeLine(' - error code: ' + resourceError.errorCode + ', description: ' + resourceError.errorString );
};
...and if I run the following line (in a Windows command prompt):
phantomjs.exe form-process.js "https://contact.site.com/auth/form?params=that&are=always&the=same" "clarence#email.com"
I get the following error:
https://contact.site.com/ajax/email-check?email=clarence#email.com"
- error code: 302,
- description: Error downloading "https://contact.site.com/ajax/email-check?email=clarence#email.com"
- server replied: Bad request
I am running this from a local environment but with no SSL certificate installed, so I assumed (based on the description of the 302 error code: the requested operation is invalid for this protocol) that it was a cross-protocol issue. But running the phantomJS line with any combination of --ssl-protocol=any, --ignore-ssl-errors=yes or --web-security=false yields the same results.
I may be misunderstanding these modes for phantomJS, but I assumed that --ssl-protocol=any would dismiss this issue, but would I still need to have a local SSL cert to get this to work? Or is there another issue here?

ADODB.Connection error from Ruby script on Apache server

I have a Ruby script (non-Rails) that connects to a SQL Server database. When run from the command line, it runs fine. When executed via an http request, it generates an error, specifically when opening the DB connection. Something about the combination of the http/SQL methods is failing.
I'm running the script on a machine with: Windows 7 Ultimate (64-bit), Ruby 1.9.3p125, Apache 2.2.11. The database is SQL Server 10.0.4000, hosted on a separate (corporate, internal) server.
The script looks something like this:
#!/Ruby193/bin/ruby
require 'win32ole'
...
$qadb = nil
begin
$qadb = SqlServer.new('192.168.100.249', 'qauser', 'password')
$qadb.open('qadb')
rescue
logRegression("Rescued: Unable to access QADB: #{$!}")
end
The SqlServer class is based on David Mullet's code, found at http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html (not copied here for brevity).
From the command line, the DB opens fine and I get an expected result from the script. When I call the script via my internal server (http://qatools/getTask.rb) I get the following error in my log file:
Rescued: Unable to access QADB: failed to create WIN32OLE object from `ADODB.Connection'
HRESULT error code:0x8007007e
The specified module could not be found.
I've considered that I might be missing a DLL. Other research led me to ntwdblib.dll -- I tried downloading a copy and placing it in various folders. I've also considered that I might be facing an Apache configuration issue and/or a security/permissions issue but I haven't found any solutions for those that seem to fit my specific problem.
Any ideas?

Resources