<prompt> Tengeneza programu ya Python kwa kutumia mfumo wa wavuti wa Pyramid unaoruhusu watumiaji kupakia faili na kuonyesha ghala la picha zilizopakiwa. Programu inapaswa kuhifadhi metadata kuhusu picha k.m., jina la faili, muhuri wa wakati wa kupakia katika hifadhidata ya PostgreSQL. PLINFORMAT  <response>: kutoka kwa pyramid.config import Configuratorkutoka kwa pyramid.response import Responsekutoka kwa pyramid.view import view_configkutoka kwa piramidi.httpisipokuwa ingiza HTTPFoundkutoka kwa pyramid.session import SignedCookieSessionFactorykuagiza oskuagiza uuidkuagiza tarehekuagiza psycopg2kutoka kwa seva ya wsgiref.simple_server make_serverdef connect_db: conn psycopg2.connectdbnamegallery userpostgres passwordyour_password kurudi conndef init_dbconn: mshale conn.cursor cursor.execute TUNZA JEDWALI IKIWA HAIPO picha id UFUNGUO WA MSINGI WA SERIAL, jina la faili TEXT NOT NULL, muhuri_wa muda wa TIMESTAMP SIO BATILI conn.commitview_configroute_namenyumbani, renderertemplateshome.jinja2def nyumbani ombi: mshale request.db.cursor cursor.executeCHAGUA KUTOKA KWA picha UTANGULIZI KWA upload_timestamp DESC picha cursor.fetchall rudisha picha: pichaview_configroute_nameupload, request_methodPOSTdef upakiaji ombi: uploaded_file request.POSTimage.faili file_extension os.path.splitextrequest.POSTimage.jina la faili-1 new_filename fuuid.uuid4file_extension target_path os.path.joinstaticuploads, new_filename na opentarget_path, wb kama output_file: wakati Kweli: data uploaded_file.read8192 ikiwa sio data: mapumziko output_file.writedata sasa datetime.datetime.now mshale request.db.cursor mshale.tekeleza INGIZA KWENYE picha jina la faili, muhuri_wa muda VALUES s, s, jina_mpya, sasa request.db.commit rudisha HTTPFoundlocationrequest.route_urlnyumbanidef mainglobal_config, mipangilio: config Configuratormipangiliomipangilio config.includepyramid_jinja2 config.add_static_viewnamestatic, pathstatic my_session_factory SignedCookieSessionFactoryyour_secret_key config.set_session_factorymy_session_factory config.add_routenyumbani, config.add_routepakia, pakia config.scan rudisha config.make_wsgi_appkama __name__ __main__: db_conn connect_db init_dbdb_conn mipangilio db: db_conn, app kuu, mipangilio seva make_server0.0.0.0, 6543, programu server.serve_forever 