How to get a response from this server? - javascript

I found this apparently lovely example of building a SQL web app online:
https://www.educative.io/answers/how-to-implement-a-frontend-for-reactjs-and-mysql-application
https://www.educative.io/answers/how-to-implement-a-server-for-reactjs-and-mysql-application
I downloaded the repository code into a structure like this:
KhalidExample
-------------------
frontend: contents of front end repository
server: contents of backend repository
I start the server code and it nicely says,
"server is running on 3002"
But then I try to visit http://localhost:3002/ and it replies
Cannot GET /
If I improve the address to match some paths that I see in the code and write
http://localhost:3002//api/get
it replies
Cannot GET //api/get
Obviously I'm missing something basic, can someone please tell me what?

Related

How to get a deployed site after I deploy moralis-admin-cli?

I have started to follow the YouTube video "Ultimate NFT Programming Tutorial - FULL COURSE" by Filip Martinsson to be able to set up everything to be able mint and sell NFT's.
I have followed his code precisely...checked everything three times...and I am at the area where I need to deploy moralis-admin-cli. I have placed a copy of what is going on shown below:
C:\metadata-static-app>moralis-admin-cli deploy
Specify Moralis Api Key: SOkdwGDLfrv4oGa
Specify Moralis Api Secret: 7FbMvOOk1EGrKKI
Following servers were found:
(0) ABC
(1) abcd
What server do you want to connect to?: 1
C:\metadata-static-app>
When I say to connect to a server, it just comes back blank as is shown in my example. It should say and show the following:
What server do you want to connect to?: 1
Deployed successfully!
Site is available at: https//lqm5lovruqm4.moralisweb3.com"
I am not sure if something else needs to be added to my laptop or really what am I doing wrong. I am really stuck. I hope someone can help me and give me some direction in what is wrong.

how to create contact us form in meteor.js

I made a contact us form and having problem that how a user submitted details will be delivered to my email.
I am newbie and do not understand this from Meteor Docs
"the MAIL_URL environment variable should be of the form smtp://USERNAME:PASSWORD#HOST:PORT/ "
I want to deploy my meteor app on Meteor free server so please guide me how i should write the above URL thing in serevr/smpt
You can have look at my source code client/templates/contact_us/contact_us.html
and
contact_us.js and server/common.js and can tell me if my rest of code is also correct to perform the contact us form functionality.
You should create an account on Mailgun (default by Meteor).
Let's say you use your gmail account which is waquar#gmail.com and your password is pass123:
Meteor.startup(function() {
process.env.MAIL_URL = 'smtp://waquar:pass123#smtp.gmail.com:587/'
});
Both your server method and client code seem to be correct, try steps above and let us know if it works.
I have in my ~/.bashrc of my dev environment something like:
export MAIL_URL='smtp://myemail%40example.com:mypass#mysmtpserver.com:587/'
You can test with a server.js like:
Email.send({
from: "meteor.email.2014#example.com",
to: "your-personal-email-here#example.com",
subject: "Meteor Can Send Emails",
text: "Its pretty easy to send emails."
});
as described in https://github.com/nelsonic/hapi-email for gmail. After receiving the test email, you can remove that file.
In production I use mup with the save env variable.

Thinkster MEAN Stack Tutorial problems with routing

I have been following this tutorial on thinkster.io:
https://thinkster.io/mean-stack-tutorial/
Everything works fine until I get to the section where we setup mongoose, then I start to hit problems.
First of all in the section "Creating Schemas with Mongoose" it says:
"Connect to our local MongoDB instance by adding the following code into our app.js file:"
But this is unclear - what do they mean by "our" app.js file - we no longer have an app.js that we created as we renamed it to angularApp.js - the only app.js file is the one generated by express/npm which is in the /views/ folder and is full of express configurations. I personally added the code to this file but am unsure if they meant for us to add it to /public/javascripts/angularApp.js
Secondly, in the "Creating our first route" section, the tutorial instructs us to add the code to routes/index.js but again this file is already populated with express routes and the tutorial is unclear as to whether we append this file with the new route for /posts or to remove the existing express route and add the /posts route instead.
Either way, the result is when I attempt to post the first data to mongodb via curl or postman it results in a 404, indicating the route is not working.
Any help appreciated - there is no comment section on the site for asking questions or troubleshooting, so I am hoping stackoverflow can fill in the gaps :)
Here's my code: https://github.com/jakblak/thinkster_mean_app
It's more organized then the original and commented.

Why can't I connect to this WDSL in Apigee

I need to connect to:
https://www.webselfstorage.com/webservices/externaldataaccessservice.asmx?WSDL
through Apigee to create a REST to SOAP to REST proxy.
I keep getting a box that pops up when I "fetch" the WSDL that reads "Server Error. Internal Error".
What Am I doing wrong here? The webservices documentation came with a username and password but there isn't a place to enter these on apigee so I have to wonder if that might be the issue.
Disclosure: I work at Apigee.
The internal error message is a problem in how we are displaying an error message when we run into a problem reading the WSDL and should be fixed in the future.
The reason it's having a problem reading your WSDL is because of this line, which exists several times in the WSDL:
<s:element ref="s:schema" />
I'm no XML expert, so what does that mean? There is a schema that contains an element that is in turn also schema? My head hurts. :)
Do you have any control over the WSDL, or is that a 3rd party WSDL that you can't modify?
I saved a copy of the file and made the following changes to get it to work. I added a line after the schema definition:
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webselfstorage.com/WebServices/ExternalDataServices">
<s:element name="schema" type="s:schema"/>
Then changed the s:schema refs to:
<s:element ref="tns:schema" />
And the fetch worked...
I'll try to follow up with more details, but just wanted to give you an update of what I've found so far.

Google Apps HTTP Streaming with Python question

I got a little question here:
Some time ago I implemented HTTP Streaming using PHP code, something similar to what is on this page:
http://my.opera.com/WebApplications/blog/show.dml/438711#comments
And I get data with very similar solution. Now I tried to use second code from this page (in Python), but no matter what I do, I receive responseText from python server after everything completes. Here are some python code:
print "Content-Type: application/x-www-form-urlencoded\n\n"
i=1
while i<4:
print("Event: server-time<br>")
print("data: %f<br>" % (time.time(),))
sys.stdout.flush()
i=i+1
time.sleep(1)
And here is Javascript Code:
ask = new XMLHttpRequest();
ask.open("GET","/Chat",true);
setInterval(function()
{
if (ask.responseText) document.write(ask.responseText);
},200);
ask.send(null);
Anyone got idea what I do wrong ? How can I receive those damn messages one after another, not just all of them at the end of while loop? Thanks for any help here!
Edit:
Main thing I forgot to add: server is google app server (i'm not sure is that google own implementation), here is a link with some explanation (i think uhh):
http://code.google.com/intl/pl-PL/appengine/docs/python/gettingstarted/devenvironment.html
http://code.google.com/intl/pl-PL/appengine/docs/whatisgoogleappengine.html
Its highly likely App Engine buffers output. A quick search found this: http://code.google.com/appengine/docs/python/tools/webapp/buildingtheresponse.html
The out stream buffers all output in memory, then sends the final output when the handler exits. webapp does not support streaming data to the client.
That looks like a cgi code - I imagine the web server buffers the response from the cgi handlers. So it's really a matter of picking the right tools and making the right configuration.
I suggest using a wsgi server and take advantage of the streaming support wsgi has.
Here's your sample code translated to a wsgi app:
def app(environ, start_response):
start_response('200 OK', [('Content-type','application/x-www-form-urlencoded')])
i=1
while i<4:
yield "Event: server-time<br>"
yield "data: %f<br>" % (time.time(),)
i=i+1
time.sleep(1)
There are plenty of wsgi servers but here's an example with the reference one from python std lib:
from wsgiref.simple_server import make_server
httpd = make_server('', 8000, app)
httpd.serve_forever()

Categories