How to set a api endpoint for json in windows? - json

I am looking for a solution to set a api end point for the json file in windows. This json should show the updated value whenever it get updated.
Can anyone help to suggest for the right approach?
Thank you

there are a million ways to do it (nginx, apache httpd, lighthttpd, IIS, even a simple netcat server could do it, to mention a few), but
the simplest way i can think of is to just host the json file from HFS
(a simple HTTP file server that runs as a single stand-alone exe, and requires no installation, and is free and open source)

Related

When does the AWS .NET SDK load credential files? Is it on startup or on initializing client or...?

As my title states, we are using the AWS .NET SDK and on our web.config configured a profile that points to a credentials file(see: https://docs.aws.amazon.com/sdk-for-net/v2/developer-guide/net-dg-config-creds.html using credentials file) on the disk(so out of the source code). This seems to work fine but we are rotating these keys every x period so we need to change the keys within the file. My question is does de AWS .NET SDK notice that the file is changed and automatically load the new credentials or when does it actually load? In other words, if we change the credentials in this file do we need to do additional steps for the application to actually use them?
What I tried now is start up the application locally, change the credentials to a faulty one and calls are still going thru without a problem. Next, I stopped my application and rebuilded in with the same file having faulty credentials. After doing this the application is still able to make correct calls so I'm wondering how this works as if it is falling back on credentials that did work. Or maybe I just didn't test right.
We are using .net framework 4.6.2 application using the aws sdk version 3.3
Also what i forgot to mention is that for each request we initialize the client like this:
using (AmazonCognitoIdentityProviderClient client = new AmazonCognitoIdentityProviderClient(regionEndpoint))
Short answer is creating a client like that will cause the credentials to be read from the credentials file when the first client is created.
The longer answer is when you create without credentials the client uses the FallbackCredentialsFactory class to find credentials either through the credentials file or environment like EC2 instance metadata. The FallbackCredentialsFactory has a static instance of Amazon.Runtime.CredentialManagement.CredentialProfileStoreChain which is what gets the credentials for a profile.
If you want to something different you could have your code create an instance of CredentialProfileStoreChain before creating a client and use that to get the credentials and pass those credentials into the client.

Cannot retrieve json data using Drupal services module with Bluehost

I am unable to view my endpoint in drupal using bluehost. I have used acquia local hosting and the data is viewable just fine via http request and through command line using curl. When I set up the site with drupal on Bluehost I receive a blank page.
with end point test:
http://parentstalkaddiction.com/test/node.json
gives me nothing
Can anyone please tell me what I might be doing wrong? Thanks in advance.
This is likely a PHP version issue. Bluehost seems to be on PHP 5.2.x and the services module uses functionality that requires PHP 5.3.x.
There is an issue open for this: https://drupal.org/node/2003396
If you don't mind applying a patch, you can do so to make it work with Bluehost's version of PHP:
https://drupal.org/files/ServicesRESTServerFactory.inc_.patch

Running json files on the apache http server (localhost)

I am trying to put a json file on a localhost to call later on my app.
How do I put the Json file on to the Apache http server to call later?
I am new to Apache http server and back end in general, I am sorry if this question is ambiguous.
I tried to look up similar questions on stackoverflow..but I just could not find any.
Just put the File into your htdocs directory. You can access it by entering in your local Browser:
http://localhost/myfilename.json

using html5 standalone app using deskshell to connect to mysql

I am making small standalone html 5 application using deskshell, I want to use MySQL database. How can I connect from JavaScript to MySQL without using PHP or server side language?
This is definitely possible using deskshell. It can be a little confusing as to what is the server and what is the client etc. Generally it is much simpler than you at first think.
I suggest the following approach. Deskshell uses an unmodified nodejs binary. So to make life simpler begin by first installing node (so it sets up everything like paths etc for you). Then use npm - the node package manager to install a module that will allow you to connect to mysql. You can go to the npm website and search for mysql. When you find a package you can npm install packagename. You can remove then afterwards with npm remove packagename. (Check website for exact syntax).
So using this approach and copying and modifying the examples from the modules homepage you should be able to get nodejs to connect to mysql and run some queries.
The next step is then to add this "database ability" to your application. Here you should realise you have 2 javascript engines running. You have one "sandboxed" v8 js engine running in the chrome browser and you then have a second "unsandboxed" v8 nodejs that will run your app.js file. I find the simplest and most pleasing way to connect the two is to use a websocket to send messages from one v8 to the other. Then you can decide the level of abstraction to write your little api at. So you could write all logic in the browser scripts, send the sql ocer the socket, nodejs app.js script then recieves message, queries mysql and returns results as json. An alternative would be you ask the api for 20 user objects and it turns the request into sql and executes it for you and returns it to the browser.
You will need to copy the node_modules/packagename folder to your application directory as node_modules/packagename. In addition you may need to change your deskshell code from require ("packagename") to be require ("./path/to/package/folder")
I would suggest you look at using sqlite3 as your database engine if a separate server is not used for your application. This is because sqlite3 is a file based in process database so you do not have to run a server process on the end users machine. However if you are connecting to an existing server database then mysql is the better option.

AS3 FTP Programming and the Socket and ByteArray Classes

Sorry for the subject line sounding like an even nerdier Harry Potter title.
I'm trying to use AS3's Socket class to write a simple FTP program to export as an AIR app in Flex Builder 3. I'm using an FTP server on my local network to test the program. I can successfully connect to the server (the easy part) but I can't send any commands. I'm pretty sure that you have to use the ByteArray class to send these commands but there's some crucial piece of information that I'm missing apparently. Does anyone know how to do this? Thanks!
Dave
The FTP protocol predates UTF encoding. Switch to ANSI/ASCII for better results. If you do opt for writeMultiByte instead of writeUTFBytes, be aware that it is buggy in linux. Here's one way around it.
There's another question here where the line ending turns out to be the culprit, so make sure that you get it right (as suggested above).
As said before, if this is running from the web, all socket connections will require a crossdomain policy, but this is NOT file based over HTTP. Recent changes to the security rules mean that any socket based connection must first get a crossdomain from a policy server hosted on port 843 of the target host.
Quoting from Adobe:
A SWF file may no longer make a socket connection to its own domain without a socket policy file. Prior to version 9,0,115,0, a SWF file was permitted to make socket connections to ports 1024 or greater in its own domain without a policy file.
HTTP policy files may no longer be used to authorize socket connections. Prior to version 9,0,115,0, an HTTP policy file, served from the master location of /crossdomain.xml on port 80, could be used to authorize a socket connection to any port 1024 or greater on the same host.
Essentially, what this means is that you must be in control of the target FTP host, and install supplementary software on it to get this working.
Read this link too and maybe it can be useful this one too.
The first one is about policy files and the second is an example of a TELNET (so, no FTP here) client.
I've been able to get an FTP client working in a browser, but it's buggy. I had to get a listener running on port 843 to server the policy file so that Flash would be allowed to connect and transfer data. Then, I had to figure out how FTP actually works:
You have to open 2 sockets: a command socket and a data socket. The command socket is where you send your USER, PASS, CWD, and STOR commands. The data socket is where you write your ByteArray data to. Sending the PASV command will tell you what port your data socket must connect to.
Where it is buggy is on Mac, in both Safari and FF, when I call the "socket.close()" command, the server socket actually closes. On Windoze, it does not. This is a huge problem because the Event.CLOSE event is not fired until the SERVER closes the connection. This is in the livedocs.
This is where I'm at. I have no idea why it would work flawlessly on Mac and then be completely busted in 3 different browsers on Windows. The only thing I can come up with is that it's either something in my Windows configuration that's preventing proper communication with the server, or it's the Window Flash player that's causing the problem.
Any thoughts?
We will need more info to resolve this.. What you're saying here appears correct to me. You're using the Socket class to send data though, not ByteArray.
Are you sure data is not being sent? How are you receiving the response? It may be that it's working fine but you're just not aware of it? As i said, tell us more about what you're doing..
Lee Brimelow has a screencast on gotoAndLearn of writing an POP3 client. It's essentially the same of what you're doing so take a look.
Are you 100% sure the syntax is correct? I know with HTTP you'll have to an include extra linebreak after the request for it to go through. Without it you'll get nothing back. Not sure how it is with FTP though.
The FTP standard requires CRLF at the end of commands. Try using "\r\n" in place of the "\n" in your example.
You must serve the CrossDomain Policy File from your FTP server in order to conect correctly.
From what I've gathered, you have to send each command one at a time and validate the response before moving on. You should be getting something back against ProgressEvent.SOCKET_DATA
Try just this and see what you get in response.
socket.writeUTFBytes("USER "+user+"\n"); socket.flush();
You would then read the response out like this.
var response:String = mySocket.readUTFBytes(mySocket.bytesAvailable);