Webserver einrichten

Published by Mario Oettler on

Last Updated on 5. September 2024 by Mario Oettler

• Öffnen Sie einen Editor Ihrer Wahl (z. B. Visual Studio Code)
• Legen Sie einen Ordner BAS2024_Praxis4 an. (Sie können den Namen aber auch frei wählen)
• Legen Sie darin eine neue Datei server_s4.js an
• Tragen Sie in dieser Datei folgenden Code ein:

var express = require("express");
var path = require("path");
var app = express();

app.listen(3000);
app.get('/', function(req, res){
console.log("Listening to Port 3000");
res.sendFile(path.join(__dirname, './','index_s4_Dapp2_02.html')); //Pfad ggf. anpassen
});

• Legen Sie eine Datei index_s4_Dapp1_01.html an.
• Fügen Sie folgenden Code ein. Diesen können Sie auch in der Datei index_s4_Dapp1_01.html finden.

<!DOCTYPE html>
<html>
    <head>
     
    </head>
    <body>
    
        <h1>My First Dapp</h1>
    
    </body>
</html>

• Speichern Sie die Datei.
• Öffnen Sie die Konsole/das Terminal
• Wechseln Sie in das Verzeichnis, in dem die Dateien server.js und index.html liegen
• Starten Sie den Server mit dem Befehl:

node server_s4.js

  • Öffnen Sie Ihren Browser
  • Geben Sie in der Adresszeile ein

localhost:3000

Es sollte folgende Seite angezeigt werden:

Categories:

https://blockchain-academy.hs-mittweida.de/wp-content/uploads/2021/04/logo_bcam_rgb_gross.png

Welcome

Blockchain Academy

Continue with credential

No account yet?

Powered by Hidy

Register with Hidy


Register
Sign in

We need the following credential to register:

please select:

To create a new account, we need the following data from you:

We would appreciate the following additional information from you for the creation of your account:

Welcome

Blockchain Academy

Continue with credential

Already have an account?

Powered by Hidy

Sign in with Hidy


Register
Sign in

We need the following credential to log in:

please select:
Do you need assistance?
Click here to open chat.

Privacy Notice: This chat sends your questions to an external AI server.
How can we help you?
  • Please note: All questions, chat history, and feedback are sent to an external AI server for processing. Do not share sensitive personal information.

    All responses are generated by AI. Independently verify and fact-check all information before use.
  • No Chat History yet, start talking...